[Seaside] jQuery questions

Rob Withers reefedjib at gmail.com
Sat Oct 9 20:39:33 UTC 2010

I am trying to understand the latest CTReport example.  Lukas recently made 
changes to allow a new item to be added.  I am confused by what exactly the 
jQuery pieces are doing.

1) In CTReport>>renderContentOn: there is some code that binds 'refresh' to 

	html table
		script: (html jQuery this
			bind: 'refresh' do: (html jQuery this load
				html: [ :h | self renderTableOn: h ]));

what does the message #this do?   What about 'html jQuery this load'. 
Obviously the html: portion is the action taken, which re-renders the table.

2) In CTReport>>renderRowView:on: there is an anchor created with an 
onClick: script:

	html tableData: [
		html anchor
			url: '#';
			" replace the owning row with an editable row "
			onClick: ((html jQuery this closest: 'tr') load
				html: [ :r | self renderRowEdit: anItem on: r ]);
			with: 'edit' ]

What does '((html jQuery this closest: 'tr') load' do?

Now some AJAX stuff...

3) In CTReport>>renderAddOn: there is jQuery...

		onClick: (html jQuery ajax script: [ :script |
			script add: ((script jQuery: 'table') append: [ :renderer |
				renderer tableRow: [
						renderRowEdit: CTReportItem new
						action: [ :item | self items add: item ]
						on: renderer ] ]) ]);

What does 'html jQuery ajax script:' do?  In the script it looks like it 
grabs the 'table' (although I don't see where the table was named) and 
appends a tableRow.

4) In CTReport>>renderRowEdit:action:on: there is more jQuery ajax....

			onClick: (html jQuery ajax
				" serialize all form elements in the table "
				serialize: ((html jQuery this closest: 'table') find: ':input');
				" trigger a refresh on all connected tables "
				html: [ :r |
					aBlock value: anItem.
					self pusher javascript: [ :s |
						s add: ((s jQuery: 'table')
							trigger: 'refresh') ] ]);

Ditto on 'jQuery ajax'?  What does 'serialize: ((html jQuery this closest: 
'table') find: ':input');' do?  Clearly the trigger: 'refresh' is sent to 
all pages the pusher knows about, right?

If there is anything else you can tell me or point me to the appropriate 
literature, it would be most appreciated!


More information about the seaside mailing list