0

In raw jQuery you can use

var $th = $td.closest('table').find('th').eq($td.index());

But, how do I return $th to seaside so I can then use it as a string for whatever rending I want? Example.

val do:[:e |
e class = Dictionary ifTrue:[
                        html tableData 
                        onDoubleClick: (html javascript alert: 'double clicked column'); 
                        with:[self renderTargets: e on: html]
                           ]
         ]

So basically I want the value of:

(((html jQuery this) next: 'td') closest: 'table'; find: 'th'; eq: ((html jQuery this) next: 'td') index; html).

and put it at the end of

...column', thValue);

I don't know javascript, jquery or ajax all that well, outside of seaside.

WWLD? Thanks

4

1 に答える 1

1

Web ページからサーバーに値を戻すには、jQuery を使用して ajax コールバックを作成できます。次のようなもの:

html tableData 
      onDoubleClick: (html jQuery ajax 
                            callback: [:v | .. do something with v... ]
                            value: ((((html jQuery this)) closest: 'table') find: 'th' ...)

#callback:value: メッセージの最初の引数 (つまり、コールバック ブロック) は、その 2 番目の引数 (つまり、javascript 式) のクライアント側評価の値でサーバー側で評価されます。

JQAjax 階層を見てください。#callback:value: メソッドには多くのバリエーションがあります (例: json、パッセンジャーなど)。

さらに、 #callback:value: コールバックを #script: などの応答レンダリング ajax コールバックと組み合わせて、クライアント側でスクリプトを実行できます。異なるコールバック ブロック間で値を渡すこともできます。

html jQuery ajax
      callback: [:v | theValue := v]
      value: ((((html jQuery this)) closest: 'table') find: 'th' ...);
      script: [:s | s << (s alert: theValue)]

上記のコードは、jQuery 式から値を取得し、それをサーバーにシリアル化し、変数に格納してから、theValueその値を表示する警告ダイアログを生成する JavaScript 応答をレンダリングします。これは明らかに、何が可能かを示すためのものです。この例では、サーバーへのコールバックはあまり役に立ちません。サーバー側の値が必要ない場合は、クライアントでプレーン Javascript を使用してください。

于 2013-01-24T21:53:46.517 に答える