[Seaside] bind onScroll event with Ajax call to body tag

Karsten Kusche karsten at heeg.de
Thu Mar 30 16:56:39 UTC 2017

Hi Sabine,

your code looks like:

html mdlLayoutContent onScroll: (html jQuery ajax script: [ :s | ... ]).

That creates two things:
html like this: <div id=„id123123“ class=„blah“></div>
javascript like: jQuery(„#id123123“).scroll(function(){jQuery.ajax….});

jQuery works by specifying a selector and then configuring the resulting objects. The selector is jQuery(„#123123“). It’ll try to find all objects with the specified ID. The configuration is the scroll-handler that you specified, it’ll be registered with the found objects.

Seaside helps here in several ways:
- when you send #onScroll: to the brush, it’ll automatically add a load-script so that the scroll-handler is registered.
- it’ll automatically register the scroll-handler for the current brush’s object, by using the brush’s ID.

As <body> cannot be accessed as a Brush, you have to do more manual work:
1. you need to add the load-script by hand (this is done by sending #addLoadScript: to the canvas’ document.
2. you need to create a jQuery instance that refers to the <body> object. This is done by calling (html jQuery: ‚body‘).
3. this jQuery instance also understands a #onScroll: method and it also registers the provided event handler.

You don’t need to modify the handler itself, it appears to return a script anyway and it doesn’t seem to do anything with the object that is scrolled.

So instead of:

html mdlLayoutContent onScroll: (html jQuery ajax script: [ :s | ... ]).

you call:

html document addLoadScript: ((html jQuery: ‚body‘) onScroll: (html jQuery ajax script: [ :s | ... ])).

Kind Regards

Am 30. März 2017 um 13:58:44, Sabine Manaa (manaa.sabine at gmail.com<mailto:manaa.sabine at gmail.com>) schrieb:
Hi Karsten,

thank you for responding!

Sorry but I have to ask how to proceed,  how to call the handler there?

What to write after onScroll: ?


2017-03-30 13:11 GMT+02:00 Karsten Kusche [via Smalltalk] <[hidden email]</user/SendEmail.jtp?type=node&node=4940539&i=0>>:
Hi Sabine,

html mdlLayoutContent
onScroll: (html jQuery ajax script: [ :s |
...do something with my model so I don't want use pure javascript... ]);
with: aBlock.

you can keep the handler and just register it with the body via:

html document addLoadScript: ((html jQuery:’body’) onScroll:…)

Kind Regards

seaside mailing list
[hidden email]<http:///user/SendEmail.jtp?type=node&node=4940527&i=0>

If you reply to this email, your message will be added to the discussion below:
To start a new topic under Seaside General, email [hidden email]</user/SendEmail.jtp?type=node&node=4940539&i=1>
To unsubscribe from bind onScroll event with Ajax call to body tag, click here.

View this message in context: Re: bind onScroll event with Ajax call to body tag<http://forum.world.st/bind-onScroll-event-with-Ajax-call-to-body-tag-tp4940510p4940539.html>
Sent from the Seaside General mailing list archive<http://forum.world.st/Seaside-General-f86180.html> at Nabble.com.
seaside mailing list
seaside at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20170330/4abaf7ef/attachment.html>

More information about the seaside mailing list