Jquery Pharo Seaside-如何在html中编辑标记后更新数据库条目

Jquery Pharo Seaside-如何在html中编辑标记后更新数据库条目,jquery,html,postgresql,pharo,seaside,Jquery,Html,Postgresql,Pharo,Seaside,我是海边的乞丐 我有一个在Pharo4.0Seaside中使用html制作的表(如电子表格),它使用车库驱动程序Seaside从PostgreSQL数据库获取数据 我将contenteditable=true放在tableData中,我可以修改它,但它不会更新数据库中的条目 我不想使用获取数据然后在单击“提交”后运行查询的表单,我只想修改电子表格单元格(html tabledata标记),然后当我按enter键(或将鼠标从单元格上取下)时,我想运行更新数据库的查询 我尝试过使用jQuery和Aj

我是海边的乞丐

我有一个在Pharo4.0Seaside中使用html制作的表(如电子表格),它使用车库驱动程序Seaside从PostgreSQL数据库获取数据

我将
contenteditable=true
放在tableData中,我可以修改它,但它不会更新数据库中的条目

我不想使用获取数据然后在单击“提交”后运行查询的表单,我只想修改电子表格单元格(html tabledata标记),然后当我按enter键(或将鼠标从单元格上取下)时,我想运行更新数据库的查询

我尝试过使用jQuery和Ajax,但无法使其正常工作。我无法获取输入的数据和描述单元格的数据,因此无法运行查询

html tableData 
attributeAt: 'contenteditable' put: 'true'; 
onClick: (html jQuery this addClass:'clicked'); 
onBlur:(self insertOrUpdateEntryWithCode: ((html jQuery this)html) withName: name forDay: day month:month year:year); 
with: value.

这个问题是不明确的,因为它与Seaside没有严格的关系,而是与应用程序的体系结构(尤其是持久性)有更多的关系

有几个问题

  • #insertorUpdateEntry with code:with name:forDay:month:year:
    做什么并返回
  • 如何访问数据库连接?(全球游泳池还是你的海滨训练?)
另外,您使用的是旧版本的Pharo,可能是旧版本的Seaside,如果需要PostgreSQL连接,我希望您使用。

然后尝试以下操作:

renderContentOn: html
  html
    table: [ 1 to: 10 do: [ :rowIndex | 
       html tableRow: [ 1 to: 5 do:
         [ :colIndex | self renderCellAtRow: rowIndex column: colIndex on: html ] ] ] ]
cellIdRow:rowdexcol:colIndex
^“rc”扩展宏:行索引:colIndex
您必须清理提交的html内容,因为新行将转换为

,如果再次提交,将转换为
br
,等等


atRow:column
返回值并设置它。我使用一个数组数组来保存结果。

该方法获取代码(我在单元格中输入的值),然后获取单元格的一些属性(表示DB表中的一些列:Name、Day等),然后使用查询插入或更新表(安全性无所谓)。我尝试使用
(htmljquerythis)html
返回标记的内容,但它只返回一个jQuery实例(可能我不太理解)。我通过海边的会议获得访问权。非常感谢你,马里戈洛先生!这意味着很多!我真的很想完成这个项目,因为我已经为这个简单的应用程序寻找了几个星期的解决方案!与数据库的连接是有效的,因为我创建了一个表单,在该表单中,我为单元格选择属性,然后插入一个值,按钮执行一个查询,插入我的新条目,但这太费力了。然后将该条目插入表中。另外,我将尝试P3驱动程序。
renderCellAtRow: rowIndex column: colIndex on: html
    ^ html tableData
        attributeAt: 'contenteditable' put: 'true';
        id: (self cellIdRow: rowIndex col: colIndex);
        onBlur:
            (html jQuery ajax
                callback: [ :v | self atRow: rowIndex column: colIndex put: v ]
                    value: html jQuery this html;
                onComplete:
                    ((html jQuery id: (self cellIdRow: rowIndex col: colIndex)) load
                        html: [ :h | h render: (self atRow: rowIndex column: colIndex) ]));
        with: (self atRow: rowIndex column: colIndex)
cellIdRow: rowIndex col: colIndex
    ^ 'r<1p>c<2p>' expandMacrosWith: rowIndex with: colIndex