Why isn’t my serverside callback occurring when I use ‘jQuery ajax’ in 2.9?

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

Why isn’t my serverside callback occurring when I use ‘jQuery ajax’ in 2.9?

Steven Noble
Hi

I haven't seen this question asked before; I apologize if it has.

I'm trying to do something like this in seaside 2.9

html button
 onClick: (html jQuery ajax
  serialize: (html jQuery this);
  script: [:s | s << (s jQuery id: stratId) append: [html text:
'bing'. html break]]);
 callback: [2 inspect];
with: 'add option'.

and as I expect my div with stratId is getting appended but I'm not
getting an inspect window in my squeak image? What's the right way to
do this?

note that I also posted this question to stackoverflow at
http://stackoverflow.com/questions/679607/why-isnt-my-serverside-callback-occuring-when-i-use-jquery-ajax-in-seaside-2-9
if someone wants to answer the question there.  Might help push
seaside out in public a bit.

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

Re: Why isn’t my serverside callback occurring when I use ‘jQuery ajax’ in 2.9?

Lukas Renggli
> I'm trying to do something like this in seaside 2.9
>
> html button
>  onClick: (html jQuery ajax
>  serialize: (html jQuery this);
>  script: [:s | s << (s jQuery id: stratId) append: [html text:
> 'bing'. html break]]);
>  callback: [2 inspect];
> with: 'add option'.
>
> and as I expect my div with stratId is getting appended but I'm not
> getting an inspect window in my squeak image? What's the right way to
> do this?

The answer is in the second part of the method comment of #serializeThis:

"Serialize the receiving element. Note that this might not work for
all form elements: (1) for check-boxes and multi-select lists Seaside
internally depends on an additional hidden form element that is
generated automatically, instead use #serializeThisWithHidden (2)
submit-button callbacks are ignored, instead use a normal callback to
trigger specific code evaluation."

Instead put your callback code into the jQuery callback itself (the
#script: block).

Cheers,
Lukas

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

Re: Why isn’t my serverside callback occurring when I use ‘jQuery ajax’ in 2.9?

Julian Fitzell-2
On Wed, Mar 25, 2009 at 12:39 AM, Lukas Renggli <[hidden email]> wrote:
> I'm trying to do something like this in seaside 2.9
>
> html button
>  onClick: (html jQuery ajax
>  serialize: (html jQuery this);
>  script: [:s | s << (s jQuery id: stratId) append: [html text:
> 'bing'. html break]]);
>  callback: [2 inspect];
> with: 'add option'.
>
> and as I expect my div with stratId is getting appended but I'm not
> getting an inspect window in my squeak image? What's the right way to
> do this?

The answer is in the second part of the method comment of #serializeThis:

"Serialize the receiving element. Note that this might not work for
all form elements: (1) for check-boxes and multi-select lists Seaside
internally depends on an additional hidden form element that is
generated automatically, instead use #serializeThisWithHidden (2)
submit-button callbacks are ignored, instead use a normal callback to
trigger specific code evaluation."

Instead put your callback code into the jQuery callback itself (the
#script: block).


This is presumably because the form doesn't actually get submitted?

Julian

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

Re: Why isn’t my serverside callback occurring when I use ‘jQuery ajax’ in 2.9?

Lukas Renggli
> This is presumably because the form doesn't actually get submitted?

#serializeThis serializes the element that triggered the event, in
this case this "would" be the button.

The reasons buttons don't serialize are indeed forms: If you serialize
multiple inputs -- for example when you serialize a series of input
fields or a complete form -- you most certainly don't want that a
random button callback (e.g. add item, save, and cancel) is triggered
(in fact, only the last one would actually be executed). That's why
button callbacks are ignored and you are asked to perform your actions
from within the callback of the AJAX element itself. It is only at
that place where you know what action to perform.

To put it simple: The original poster created a AJAX callback that was
supposed to trigger a button callback. Instead of doing this
unnecessary indirection why not simply call the button action from the
AJAX callback?

Lukas

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

Re: Why isn’t my serverside callback occurring when I use ‘jQuery ajax’ in 2.9?

Steven Noble
Thanks Lukas,

That makes a lot of sense.  Putting the code in the script block was
my first instinct but I got thrown off by the name.

Thanks again,
Steven

On Wed, Mar 25, 2009 at 1:30 AM, Lukas Renggli <[hidden email]> wrote:

>> This is presumably because the form doesn't actually get submitted?
>
> #serializeThis serializes the element that triggered the event, in
> this case this "would" be the button.
>
> The reasons buttons don't serialize are indeed forms: If you serialize
> multiple inputs -- for example when you serialize a series of input
> fields or a complete form -- you most certainly don't want that a
> random button callback (e.g. add item, save, and cancel) is triggered
> (in fact, only the last one would actually be executed). That's why
> button callbacks are ignored and you are asked to perform your actions
> from within the callback of the AJAX element itself. It is only at
> that place where you know what action to perform.
>
> To put it simple: The original poster created a AJAX callback that was
> supposed to trigger a button callback. Instead of doing this
> unnecessary indirection why not simply call the button action from the
> AJAX callback?
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> 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