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