Submitting forms using Ajax

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

Submitting forms using Ajax

Stevie Bornschein
Hi there,

I am building a Magritte form and want to submit it using Ajax. The reason is that, depending on the value of a select list, some of the other inputs of the form have to be hidden or visible. In case users change the value of the select list I want to save their changes and show the reduced or extended form on the fly.

At the moment I reload the whole form using a Scriptaculous updater (that works fine), but I have difficulties to save the updated model values. Obviously, the form's contents will be reset if I don’t save them.

Does anyone have an idea how to save the form manually, without pressing the 'submit' button and without reloading the whole page?

Cheers,
Stevie

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

Re: Submitting forms using Ajax

sebastianconcept@gmail.co

onReactingToSomethingOn: html
| anUpdater |

anUpdater := self makeUpdaterOn: html.

anUpdater triggerForm: 'yourFormId'


gives you ideas?




On May 18, 2011, at 9:42 AM, Stevie Bornschein wrote:

Hi there,

I am building a Magritte form and want to submit it using Ajax. The reason is that, depending on the value of a select list, some of the other inputs of the form have to be hidden or visible. In case users change the value of the select list I want to save their changes and show the reduced or extended form on the fly.

At the moment I reload the whole form using a Scriptaculous updater (that works fine), but I have difficulties to save the updated model values. Obviously, the form's contents will be reset if I don’t save them.

Does anyone have an idea how to save the form manually, without pressing the 'submit' button and without reloading the whole page?

Cheers,
Stevie
_______________________________________________
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: Submitting forms using Ajax

Stevie Bornschein
Hi Sebastian,

thanks for replying so fast. Sadly I’m not so versed in SeaSide yet—could you explain further? I already tried to use the triggerForm message, but I don’t exactly know what to do in order to submit the form eventually.

Many thanks,
Stevie

2011/5/18 Sebastian Sastre <[hidden email]>

onReactingToSomethingOn: html
| anUpdater |

anUpdater := self makeUpdaterOn: html.

anUpdater triggerForm: 'yourFormId'


gives you ideas?




On May 18, 2011, at 9:42 AM, Stevie Bornschein wrote:

Hi there,

I am building a Magritte form and want to submit it using Ajax. The reason is that, depending on the value of a select list, some of the other inputs of the form have to be hidden or visible. In case users change the value of the select list I want to save their changes and show the reduced or extended form on the fly.

At the moment I reload the whole form using a Scriptaculous updater (that works fine), but I have difficulties to save the updated model values. Obviously, the form's contents will be reset if I don’t save them.

Does anyone have an idea how to save the form manually, without pressing the 'submit' button and without reloading the whole page?

Cheers,
Stevie
_______________________________________________
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



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

Re: Submitting forms using Ajax

Johan Brichau-2
In reply to this post by Stevie Bornschein

On 18 May 2011, at 14:42, Stevie Bornschein wrote:

> Does anyone have an idea how to save the form manually, without pressing the 'submit' button and without reloading the whole page?

If I understand your problem correctly, you can use the #onChange: handler on each field of the form to trigger a serialization of the form.
I have never used Scriptaculous in Seaside, so I will give an example using jQuery:

html textInput
        callback:[:val | text := val];
        onChange: (html jQuery ajax serializeThis).


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

Re: Submitting forms using Ajax

John McKeon
In reply to this post by Stevie Bornschein
Hello Stevie,
With regular Seaside components you want to use #serializeThis (I think Scriptaculous has that selector?) in an onChange or similar event for those components that you want to submit individually. This causes the callback attached to the component to execute.
 
The trouble is that Magritte Seaside components don't know anything about javascript. They don't render any javascript, so you have to create your own components that will render the javascript AND render it based only on the description(s) of your model. Not trivial.
 
I have had good (dare I say exceptional) results doing so with jQuery, but it is not that simple a task (and it is not all that pretty - yet). If you are daring you can look at Magritte-JQueryWidgetBox
 
Hope this helps
John
On Wed, May 18, 2011 at 8:53 AM, Stevie Bornschein <[hidden email]> wrote:
Hi Sebastian,

thanks for replying so fast. Sadly I’m not so versed in SeaSide yet—could you explain further? I already tried to use the triggerForm message, but I don’t exactly know what to do in order to submit the form eventually.

Many thanks,
Stevie


2011/5/18 Sebastian Sastre <[hidden email]>

onReactingToSomethingOn: html
| anUpdater |

anUpdater := self makeUpdaterOn: html.

anUpdater triggerForm: 'yourFormId'


gives you ideas?


o/



On May 18, 2011, at 9:42 AM, Stevie Bornschein wrote:

Hi there,

I am building a Magritte form and want to submit it using Ajax. The reason is that, depending on the value of a select list, some of the other inputs of the form have to be hidden or visible. In case users change the value of the select list I want to save their changes and show the reduced or extended form on the fly.

At the moment I reload the whole form using a Scriptaculous updater (that works fine), but I have difficulties to save the updated model values. Obviously, the form's contents will be reset if I don’t save them.

Does anyone have an idea how to save the form manually, without pressing the 'submit' button and without reloading the whole page?

Cheers,
Stevie
_______________________________________________
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



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




--
http://john-mckeon.us

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