Catching form_remote_tag response

28 views
Skip to first unread message

Khepin

unread,
Sep 9, 2010, 8:22:40 AM9/9/10
to sfJqueryReloadedPlugin
Hello,

Using the form remote tag. Everything seems to work as required.
However depending what happens to the form I want to have different
behaviors. Mainly if it was not valid, the default behavior of
redisplaying it is perfect, but if it was valid, I want to stop
displaying it and update some other components of my page.

The only way I have found to do so for now is to set a different
response when my form was valid. Mainly I just send back 'true', and
then the function that I declared as the 'complete' callback checks
that element to see if we received 'true'.
But it would be easier if I could declare
'complete' => 'updatePage(response)'
and directly use that response.

Is there a way that I can do so?

Thanks
Seb

Tom Boutell

unread,
Sep 9, 2010, 9:00:58 AM9/9/10
to sfjqueryrel...@googlegroups.com
The purpose of the jquery helpers is to let you port code that used
the old prototype helpers. When you find yourself wanting to go beyond
that set of features, think about just using jQuery directly. Read the
documentation for $.get, $.post and $.ajax, you'll be surprised by how
simple they are. We're moving away from the jQuery helpers ourselves
(it just takes time to rewrite so many calls to them).

$.get(<?php echo json_encode(url_for('my/action')) ?>, { js:
parameters }, function(data) { $('#foo').html(data); });

Really simple and powerful stuff.

--
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

Sebastien Armand [Pink]

unread,
Sep 10, 2010, 2:28:40 AM9/10/10
to sfjqueryrel...@googlegroups.com
Thanks!

It is indeed quite easy to do everything with jQuery directly!
Reply all
Reply to author
Forward
0 new messages