Form extended with ajax and callbacks

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

Form extended with ajax and callbacks

NorbertHartl
I'm asking myself if I do something wrong or if it is not supported in seaside. I have a form that is rendered the first time. The form includes a select that when being changed triggers an ajax call and this inserts a new input field inside the form. Should it work that I get a value from the input field when the form is being submitted?

thanks,

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

Re: Form extended with ajax and callbacks

Paul DeBruicker
On 11-12-02 07:57 AM, Norbert Hartl wrote:
> I'm asking myself if I do something wrong or if it is not supported in seaside. I have a form that is rendered the first time. The form includes a select that when being changed triggers an ajax call and this inserts a new input field inside the form. Should it work that I get a value from the input field when the form is being submitted?
>
> thanks,
>
> Norbert_______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


I would have guessed that would work.  Is it a textInput or something
that requires you to serializeWithHidden?  Does your input have a 'name'
property after its inserted? Does the input's id or name conflict with
anything else in the page/form? Can you see in Firebug if the parameter
is sent back to Seaside?  Why not just show/hide the textInput?  Are you
submitting the form with ajax or in the traditional way?
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Form extended with ajax and callbacks

NorbertHartl

Am 02.12.2011 um 17:25 schrieb Paul DeBruicker:

> On 11-12-02 07:57 AM, Norbert Hartl wrote:
>> I'm asking myself if I do something wrong or if it is not supported in seaside. I have a form that is rendered the first time. The form includes a select that when being changed triggers an ajax call and this inserts a new input field inside the form. Should it work that I get a value from the input field when the form is being submitted?
>>
>> thanks,
>>
>> Norbert_______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> I would have guessed that would work.  Is it a textInput or something that requires you to serializeWithHidden?  Does your input have a 'name' property after its inserted? Does the input's id or name conflict with anything else in the page/form? Can you see in Firebug if the parameter is sent back to Seaside?  Why not just show/hide the textInput?  Are you submitting the form with ajax or in the traditional way?
Paul,

it is a text input field . It has name property and it is transferred to the server. I cannot see anything the input field conflicts with. I don't use toggle because I don't know upfront what has to be inserted. The select field selects a class that is transferred to the server. There a new instance is created and it is returned as magritte component. So I need the extra roundtrip.

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

Re: Form extended with ajax and callbacks

NorbertHartl

Am 02.12.2011 um 17:45 schrieb Norbert Hartl:

>
> Am 02.12.2011 um 17:25 schrieb Paul DeBruicker:
>
>> On 11-12-02 07:57 AM, Norbert Hartl wrote:
>>> I'm asking myself if I do something wrong or if it is not supported in seaside. I have a form that is rendered the first time. The form includes a select that when being changed triggers an ajax call and this inserts a new input field inside the form. Should it work that I get a value from the input field when the form is being submitted?
>>>
>>> thanks,
>>>
>>> Norbert_______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>> I would have guessed that would work.  Is it a textInput or something that requires you to serializeWithHidden?  Does your input have a 'name' property after its inserted? Does the input's id or name conflict with anything else in the page/form? Can you see in Firebug if the parameter is sent back to Seaside?  Why not just show/hide the textInput?  Are you submitting the form with ajax or in the traditional way?
> Paul,
>
> it is a text input field . It has name property and it is transferred to the server. I cannot see anything the input field conflicts with. I don't use toggle because I don't know upfront what has to be inserted. The select field selects a class that is transferred to the server. There a new instance is created and it is returned as magritte component. So I need the extra roundtrip.
>
Ok, I've found the problem. As it is all the same form I submit it twice. Once for the transfer of the select value and the second time when using the submit button. The select callback is triggered a second time and the magritte component gets resetted and that is the reason I can't see the value. I'm not sure what is the best solution to it. Is it possible to submit only a subset of the form fields? Otherwise I need to detect this case somehow.

Norbert

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

Re: Form extended with ajax and callbacks

Paul DeBruicker
On 11-12-02 09:21 AM, Norbert Hartl wrote:
> Ok, I've found the problem. As it is all the same form I submit it twice. Once for the transfer of the select value and the second time when using the submit button. The select callback is triggered a second time and the magritte component gets resetted and that is the reason I can't see the value. I'm not sure what is the best solution to it. Is it possible to submit only a subset of the form fields? Otherwise I need to detect this case somehow.
>
> Norbert


Could you just make a generic textInput that stores into an inst var in
the component whatever value you want in the class the select chooses,
then do the instance creation and set the value once the form is submitted?
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Form extended with ajax and callbacks

NorbertHartl

Am 02.12.2011 um 18:25 schrieb Paul DeBruicker:

> On 11-12-02 09:21 AM, Norbert Hartl wrote:
>> Ok, I've found the problem. As it is all the same form I submit it twice. Once for the transfer of the select value and the second time when using the submit button. The select callback is triggered a second time and the magritte component gets resetted and that is the reason I can't see the value. I'm not sure what is the best solution to it. Is it possible to submit only a subset of the form fields? Otherwise I need to detect this case somehow.
>>
>> Norbert
>
>
> Could you just make a generic textInput that stores into an inst var in the component whatever value you want in the class the select chooses, then do the instance creation and set the value once the form is submitted?

That wouldn't work. I need only one text input because the selected class is the simplest one of all possible. For every other case there will be multiple form elements that form a new instance. So the delegating component needs to be agnostic of the selected instance. As it is a select I just switch cases and there is no need to reset the child component unless the selection has changed. This way it works quite ok.

thanks,

Norbert

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

Re: Form extended with ajax and callbacks

Ryan Simmons-2

Here are a few things you could try.

1. Move the select outside the form. Because it is serialized with ajax it should be fine.
2. Remove the select using javascript in a onClick event on the submit button, something like onClick: ((html jQuery id: selectId) remove; return: true)
3. Use ajax to serialize the form elements by giving them a common class and using a standard button with a
onClick: ((html jQuery ajax
    serialize: (html jQuery: '.commonCssClass');
    Script: [:s | s callback: [current callback on submit button]

On Dec 2, 2011 7:36 PM, "Norbert Hartl" <[hidden email]> wrote:

Am 02.12.2011 um 18:25 schrieb Paul DeBruicker:

> On 11-12-02 09:21 AM, Norbert Hartl wrote:
>> Ok, I've found the problem. As it is all the same form I submit it twice. Once for the transfer of the select value and the second time when using the submit button. The select callback is triggered a second time and the magritte component gets resetted and that is the reason I can't see the value. I'm not sure what is the best solution to it. Is it possible to submit only a subset of the form fields? Otherwise I need to detect this case somehow.
>>
>> Norbert
>
>
> Could you just make a generic textInput that stores into an inst var in the component whatever value you want in the class the select chooses, then do the instance creation and set the value once the form is submitted?

That wouldn't work. I need only one text input because the selected class is the simplest one of all possible. For every other case there will be multiple form elements that form a new instance. So the delegating component needs to be agnostic of the selected instance. As it is a select I just switch cases and there is no need to reset the child component unless the selection has changed. This way it works quite ok.

thanks,

Norbert

_______________________________________________
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