Dynamic Web Development with Seaside

Buy PDF Buy Print

21.3Adding jQuery

After creating a jQuery object on the Smalltalk side it is time to investigate on how to add them to the Seaside application.

The standard way of doing so in jQuery is to keep all the Javascript functionality unobtrusive in a separate Javascript file. This is possible with Seaside, but not the suggested way. In Seaside we try to encapsulate views and view-related functionality in components. Furthermore we keep components independent of each other and reusable in different contexts, what does not work well with sharing unobtrusive Javascript code. Additionally, the unobtrusiveness comes into the way when we want to define AJAX interactions.

Attaching to Element

html anchor
onClick: (html jQuery: 'div')
remove;
with: 'Remove DIVs'
html anchor
onClick: (html jQuery this)
remove;
with: 'Remove Myself'

Execute at Load-Time

  • Forget about $(document).ready(...)
  • Seaside has its own mechanism there
html document addLoadScript: (html jQuery: 'div') remove
§
jQuery
Ajax
Performing Actions
This is a draft chapter. Please help improving it by leaving a comment in the notes or by contributing text and examples.

User Contributed Notes

nick.ager (19 June 2011, 11:57 am)

From the comment in JQueryClass>>#ready:

"Binds a function to be executed whenever the DOM is ready to be traversed and manipulated. Note: Do not combine the jQuery ready-function and the Seaside mechanism (WAHtmlDocument>>#addLoadScript:) to add load-scripts. The queues of these two mechanisms are independent and conflict with each other. The execution order of the scripts is undefined. Preferably use the mechanism of Seaside: it transfers less bytes over the network and reliably works for full requests and AJAX callbacks."

 

I can understand that the execution order is undefined but why do they conflict? Do they conflict only when the script generator is WADefaultScriptGenerator not JQScriptGenerator?

 

Be great if this could be expanded upon as the comment isn't clear to me

Add a Note

Copyright © 17 May 2012 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.