Hi,
til now, I was adding an onScroll event (with an Ajax call) to a part of my layout like this here: html mdlLayoutContent onScroll: (html jQuery ajax script: [ :s | ...do something with my model so I don't want use pure javascript... ]); with: aBlock. This worked fine. But now I have to change this and I have to put the onScroll event to the body tag: I know that I could in updateRoot do this: aHtmlRoot bodyAttributes at: 'onScroll' put: 'alert(''D'')'. But I have to make an Ajax call (getting next domain objects to show). So my question is how can can I put an Ajax call to body onScroll that the result is similar to this: <body onscroll="if( do some js check){$.ajax({"dataType":"script","url":"/RKA","data":["_s=KFxTxw2Prts-ZMLU","_k=Zp8eG2nIxTNYJAlE","37"].join("&")})}"> I would be very happy for a hint... Sabine |
Hi Sabine,
html document addLoadScript: ((html jQuery:’body’) onScroll:…)
Kind Regards
Karsten
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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: ? Regards Sabine 2017-03-30 13:11 GMT+02:00 Karsten Kusche [via Smalltalk] <[hidden email]>:
|
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
Karsten
Am 30. März 2017 um 13:58:44, Sabine Manaa ([hidden email]) schrieb:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Karsten, thank you very much for the explanation. It helped to come one step further. I tried this but it did not work. Now I know it is because I have to find a problem with the scroll event because with onClick it works. Have a nice day Sabine 2017-03-30 18:48 GMT+02:00 Karsten Kusche [via Smalltalk] <[hidden email]>:
|
Free forum by Nabble | Edit this page |