[Seaside] Detect the position of a page div
Robert Sirois
watchlala at hotmail.com
Wed Sep 23 16:31:17 UTC 2009
I see how it works now. The js functions are captured in the callbacks, and the callbacks are triggered when an event takes place (in this case #onDrag:). Here is my updated code:
html div
id: 'areaView';
script: ((html jQuery new draggable) grid: #(150 150); onDrag: (
html jQuery ajax
callback: [:value | self top: value] value: (html jQuery this offset access: 'top');
callback: [:value | self left: value] value: (html jQuery this offset access: 'left')
)
);
with: ["..."].
One thing I just realized is that #onDrag: is trigged as long as the dealy bob (html element) is bein dragged, but not at a regular consistency. Even with the grid function, it still can't keep up with what I'm doin on the page. I havn't tried it yet, but I was thinking maybe I could use scrollspeed or something to fix this little problem... or maybe it doesn't matter. I suppose it's updating the offset correctly, so if it skips a few movements, the smoothness of what I'm doing with this data will just be a little... well, less smooth.
Anyway, I had a question about the primary/secondary callbacks again:
Lukas:
"
You can only register one primary callback for an ajax object, e.g.
html jQuery ajax callback: [ ... ]; callback: [ ... ] " <-- wrong "
does not make sense, because Seaside returns a response after
processing the primary callback. However you can register as many
secondary callbacks as you want, e.g. to serialize values to the
server:
html jQuery ajax " <-- correct "
callback: [ :v1 | "this is a secondary callback" ] value: ....;
callback: [ :v2 | "this is a secondary callback" ] value: ....;
html: [ :h | "this is a primary callback that generates html,
internally it calls #callback:" ];
...
Note that the primary callback is always evaluated last, whereas the
secondary callback are evaluated before in order they were defined.
"
So if I am passing a value to the callback it is considered a secondary callback because it doesn't have to
go and find values or something? Sorry, would you mind explaining it again?
Thanks!
RS
> Date: Wed, 23 Sep 2009 08:28:17 +0200
> Subject: Re: [Seaside] Detect the position of a page div
> From: renggli at gmail.com
> To: seaside at lists.squeakfoundation.org
>
> > Alright, I think I'm starting to understand the process of events here. What
> > I'm still confused about, however, is exactly what "#text:" does. How is it
> > able to render the value of "((html jQuery: #whatever) offset access:
> > 'top')" when I can't assign that value to a component variable, render it
> > with "#html:", or even show it with Transcript? Is that because the function
> > has to be rendered (for JavaScript to deal with) first?
>
> Unless you use AJAX, all the code execution happens in Javascript in
> the web browser:
>
> (html jQuery: #foo) text: (html jQuery: #bar) offsetLeft
>
> In this case the expression is transformed to Javascript something
> along the following lines:
>
> $("#foo").text($("#bar").offset.left)
>
> Have a look at the generated code in FireBug.
>
> > How can I get the offset value and store it in an instance variable then?
>
> Attach this script to the #onStop: handler of the draggable:
>
> html ajax
> callback: [ :value | left := value ] value: (html jQuery: #bar) offsetLeft;
> callback: [ :value | top := value ] value: (html jQuery: #bar) offsetTop
>
> Again check out the generated code in FireBug and inspect the request
> it triggers off.
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_________________________________________________________________
Bing™ brings you maps, menus, and reviews organized in one place. Try it now.
http://www.bing.com/search?q=restaurants&form=MLOGEN&publ=WLHMTAG&crea=TEXT_MLOGEN_Core_tagline_local_1x1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20090923/fa9d67d6/attachment.htm
More information about the seaside
mailing list