bind onScroll event with Ajax call to body tag

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

bind onScroll event with Ajax call to body tag

Sabine Manaa
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({&quot;dataType&quot;:&quot;script&quot;,&quot;url&quot;:&quot;/RKA&quot;,&quot;data&quot;:[&quot;_s=KFxTxw2Prts-ZMLU&quot;,&quot;_k=Zp8eG2nIxTNYJAlE&quot;,&quot;37&quot;].join(&quot;&amp;&quot;)})}">

I would be very happy for a hint...
Sabine
Reply | Threaded
Open this post in threaded view
|

Re: bind onScroll event with Ajax call to body tag

Karsten Kusche
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
Karsten

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: bind onScroll event with Ajax call to body tag

Sabine Manaa
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,


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
Karsten

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/bind-onScroll-event-with-Ajax-call-to-body-tag-tp4940510p4940527.html
To start a new topic under Seaside General, email [hidden email]
To unsubscribe from bind onScroll event with Ajax call to body tag, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: bind onScroll event with Ajax call to body tag

Karsten Kusche
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:
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,


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
Karsten

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/bind-onScroll-event-with-Ajax-call-to-body-tag-tp4940510p4940527.html
To start a new topic under Seaside General, email [hidden email]
To unsubscribe from bind onScroll event with Ajax call to body tag, click here.
NAML



View this message in context: Re: bind onScroll event with Ajax call to body tag
Sent from the Seaside General mailing list archive at Nabble.com.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: bind onScroll event with Ajax call to body tag

Sabine Manaa
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]>:
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:
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,


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
Karsten

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/bind-onScroll-event-with-Ajax-call-to-body-tag-tp4940510p4940527.html
To start a new topic under Seaside General, email [hidden email]
To unsubscribe from bind onScroll event with Ajax call to body tag, click here.
NAML



View this message in context: Re: bind onScroll event with Ajax call to body tag
Sent from the Seaside General mailing list archive at Nabble.com.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/bind-onScroll-event-with-Ajax-call-to-body-tag-tp4940510p4940584.html
To start a new topic under Seaside General, email [hidden email]
To unsubscribe from bind onScroll event with Ajax call to body tag, click here.
NAML