Submiting a form with a confirmation dialog (jquery) does not work properly

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

Submiting a form with a confirmation dialog (jquery) does not work properly

EstebanLM
Hi,
I'm trying to add a "confirmation dialog" using jQuery in a form, and calling submit from a jquery statement is not working properly (or at least, is not working as I was hoping to work). If I submit the form using javascript, I was expecting #defaultAction: to be called, but no :(

Does anybody knows how can I do this properly?

In the example, I render a dialog (with a form), then a form, and the "accept" button opens the dialog. The accept button in the dialog triggers my confirmation dialog and on complete submits the original form.

This is the code:

renderDialogCollectExtraInfoOn: html
        | dialogId formId dialogFormId |

        dialogId := html nextId.
        dialogFormId := html nextId.
        formId := html nextId.
       
        html heading
                level2;
                with: 'Collect extra information in confirmation dialog'.
       
        html div
                id: dialogId;  
                script: (html jQuery this dialog
                        title: 'Dialog with extra info';
                        resizable: false;
                        modal: true;
                        autoOpen: false;
                        addButton: 'Accept' do: (html jQuery ajax
                                serializeForm: (html jQuery id: dialogFormId);
                                onComplete: ((html jQuery id: formId) call: 'submit'));
                        addButton: 'Cancel' do: (html jQuery this dialog close));
                with: [
                        html form
                                id: dialogFormId;
                                with: [
                                        html checkbox
                                                on: #confirm1 of: self;
                                                with: 'Confirm 1' ] ].
       
        html form
                id: formId;
                defaultAction: [ self halt. self inform: 'Ok'. "I'm expecting this to be executed" ];
                with: [
                        html text: 'Some text: '.
                        html textInput on: #text of: self.

                        html button
                                onClick: (html javascript
                                        add: ((html jQuery id: dialogId) dialog open);
                                        add: (JSStream on: 'return false');
                                        yourself);
                                callback: [ self halt. "I'm not expecting this to be executed" ];
                                with: 'Accept' ]

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

Re: Submiting a form with a confirmation dialog (jquery) does not work properly

sebastianconcept@gmail.co
did you tried:

thatSubmitButton.click()

?





On Mar 16, 2011, at 7:27 PM, Esteban Lorenzano wrote:

Hi,
I'm trying to add a "confirmation dialog" using jQuery in a form, and calling submit from a jquery statement is not working properly (or at least, is not working as I was hoping to work). If I submit the form using javascript, I was expecting #defaultAction: to be called, but no :(

Does anybody knows how can I do this properly?

In the example, I render a dialog (with a form), then a form, and the "accept" button opens the dialog. The accept button in the dialog triggers my confirmation dialog and on complete submits the original form.

This is the code:

renderDialogCollectExtraInfoOn: html
| dialogId formId dialogFormId |

dialogId := html nextId.
dialogFormId := html nextId.
formId := html nextId.

html heading
level2;
with: 'Collect extra information in confirmation dialog'.

html div
id: dialogId;  
script: (html jQuery this dialog
title: 'Dialog with extra info';
resizable: false;
modal: true;
autoOpen: false;
addButton: 'Accept' do: (html jQuery ajax
serializeForm: (html jQuery id: dialogFormId);
onComplete: ((html jQuery id: formId) call: 'submit'));
addButton: 'Cancel' do: (html jQuery this dialog close));
with: [
html form
id: dialogFormId;
with: [
html checkbox
on: #confirm1 of: self;
with: 'Confirm 1' ] ].

html form
id: formId;
defaultAction: [ self halt. self inform: 'Ok'. "I'm expecting this to be executed" ];
with: [
html text: 'Some text: '.
html textInput on: #text of: self.

html button
onClick: (html javascript
add: ((html jQuery id: dialogId) dialog open);
add: (JSStream on: 'return false');
yourself);
callback: [ self halt. "I'm not expecting this to be executed" ];
with: 'Accept' ]

Thanks,
Esteban_______________________________________________
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: Submiting a form with a confirmation dialog (jquery) does not work properly

Diogenes Moreira
In reply to this post by EstebanLM

Well I'll guessing this reponse but Im deduce this form html code :)

the deault acction is implemented by a hidden submit input.. <input type="submit" class="submit" style="position: absolute; top: -100em;" name="7" value="Default" tabindex="-1">.. in a hidden div or a text input if your browser is explorer.

In other situation when you press enter the post have your field values and the variable 7=Default,,, 7 is an id on the fly generated. that value identify the default block in the WeakDictionary of the session.

When you do submit via jquery the "7" field is'nt setting, because, nothing happend when you are do submit via Jquery.

For obteing your expecting behiavior i suggest 3 way.

1. Extend WAFormTag for obteing or assing the id for the default action control, and then do submit
2. Or Implement you own hidden button.
3. Obteing the id and value to defaultAction continuation and set this variable en your post..

That Solution don't be beatyfull but must work..

Best.



On Wed, Mar 16, 2011 at 7:27 PM, Esteban Lorenzano <[hidden email]> wrote:
Hi,
I'm trying to add a "confirmation dialog" using jQuery in a form, and calling submit from a jquery statement is not working properly (or at least, is not working as I was hoping to work). If I submit the form using javascript, I was expecting #defaultAction: to be called, but no :(

Does anybody knows how can I do this properly?

In the example, I render a dialog (with a form), then a form, and the "accept" button opens the dialog. The accept button in the dialog triggers my confirmation dialog and on complete submits the original form.

This is the code:

renderDialogCollectExtraInfoOn: html
       | dialogId formId dialogFormId |

       dialogId := html nextId.
       dialogFormId := html nextId.
       formId := html nextId.

       html heading
               level2;
               with: 'Collect extra information in confirmation dialog'.

       html div
               id: dialogId;
               script: (html jQuery this dialog
                       title: 'Dialog with extra info';
                       resizable: false;
                       modal: true;
                       autoOpen: false;
                       addButton: 'Accept' do: (html jQuery ajax
                               serializeForm: (html jQuery id: dialogFormId);
                               onComplete: ((html jQuery id: formId) call: 'submit'));
                       addButton: 'Cancel' do: (html jQuery this dialog close));
               with: [
                       html form
                               id: dialogFormId;
                               with: [
                                       html checkbox
                                               on: #confirm1 of: self;
                                               with: 'Confirm 1' ] ].

       html form
               id: formId;
               defaultAction: [ self halt. self inform: 'Ok'. "I'm expecting this to be executed" ];
               with: [
                       html text: 'Some text: '.
                       html textInput on: #text of: self.

                       html button
                               onClick: (html javascript
                                       add: ((html jQuery id: dialogId) dialog open);
                                       add: (JSStream on: 'return false');
                                       yourself);
                               callback: [ self halt. "I'm not expecting this to be executed" ];
                               with: 'Accept' ]

Thanks,
Esteban_______________________________________________
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: Submiting a form with a confirmation dialog (jquery) does not work properly

Diogenes Moreira
Hi Folks.. I'm send to you a proposal to solve the problem reported by esteban..

Basicly im adding a hidden value with the default action id in the WACallbackRegistry. and this callback is evaluate when no other action is evaluate.

Best.


WACallback>>isAction
^ false.

WAActionCallback>>isAction
^ true.


WACallbackRegistry>>handle: aRequestContext
| set fields |
set := Set new.
fields := aRequestContext request fields.
fields keysDo: [ :key | 
callbacks at: key ifPresent: [ :callback | 
(callback isEnabledFor: aRequestContext)
ifTrue: [ set add: callback ] ] ].
set sorted  do: [ :callback | callback evaluateWithFieldValues: (fields allAt: callback key) ].
(set anySatisfy:[ :callback | callback  isAction ])  ifFalse: [ 
fields at: '_d' ifPresent: [ :key | 
callbacks at: key ifPresent: [ :callback | 
(callback isEnabledFor: aRequestContext) ifTrue: [ 
callback evaluateWithFieldValues: (fields allAt: callback key) ]]]]


WAFormTag>>before
"Define the default action form buttons. Some implementation notes on this feature: (1) a tab-index of -1 is not valid XHTML, but most todays browser accept it and ignore the element in the tab-order. (2) Internet Explorer requires an additional text field (without other functionality) to make the default action work. Other browser should not include this text-field, as it prevents remembering form input."

super before.
defaultAction ifNil: [ ^ nil ].
canvas div: [ |button|
button:= canvas submitButton
tabIndex: -1;
value: 'Default';
callback: defaultAction;
style: 'position: absolute; top: -100em'.
canvas hiddenInput name:'_d'; value: (button attributeAt: 'name').
self isInternetExplorer ifTrue: [
canvas textInput
tabIndex: -1;
callback: [ :v | ];
style: 'position: absolute; top: -100em' ] ]


On Wed, Mar 16, 2011 at 11:45 PM, Diogenes Moreira <[hidden email]> wrote:

Well I'll guessing this reponse but Im deduce this form html code :)

the deault acction is implemented by a hidden submit input.. <input type="submit" class="submit" style="position: absolute; top: -100em;" name="7" value="Default" tabindex="-1">.. in a hidden div or a text input if your browser is explorer.

In other situation when you press enter the post have your field values and the variable 7=Default,,, 7 is an id on the fly generated. that value identify the default block in the WeakDictionary of the session.

When you do submit via jquery the "7" field is'nt setting, because, nothing happend when you are do submit via Jquery.

For obteing your expecting behiavior i suggest 3 way.

1. Extend WAFormTag for obteing or assing the id for the default action control, and then do submit
2. Or Implement you own hidden button.
3. Obteing the id and value to defaultAction continuation and set this variable en your post..

That Solution don't be beatyfull but must work..

Best.



On Wed, Mar 16, 2011 at 7:27 PM, Esteban Lorenzano <[hidden email]> wrote:
Hi,
I'm trying to add a "confirmation dialog" using jQuery in a form, and calling submit from a jquery statement is not working properly (or at least, is not working as I was hoping to work). If I submit the form using javascript, I was expecting #defaultAction: to be called, but no :(

Does anybody knows how can I do this properly?

In the example, I render a dialog (with a form), then a form, and the "accept" button opens the dialog. The accept button in the dialog triggers my confirmation dialog and on complete submits the original form.

This is the code:

renderDialogCollectExtraInfoOn: html
       | dialogId formId dialogFormId |

       dialogId := html nextId.
       dialogFormId := html nextId.
       formId := html nextId.

       html heading
               level2;
               with: 'Collect extra information in confirmation dialog'.

       html div
               id: dialogId;
               script: (html jQuery this dialog
                       title: 'Dialog with extra info';
                       resizable: false;
                       modal: true;
                       autoOpen: false;
                       addButton: 'Accept' do: (html jQuery ajax
                               serializeForm: (html jQuery id: dialogFormId);
                               onComplete: ((html jQuery id: formId) call: 'submit'));
                       addButton: 'Cancel' do: (html jQuery this dialog close));
               with: [
                       html form
                               id: dialogFormId;
                               with: [
                                       html checkbox
                                               on: #confirm1 of: self;
                                               with: 'Confirm 1' ] ].

       html form
               id: formId;
               defaultAction: [ self halt. self inform: 'Ok'. "I'm expecting this to be executed" ];
               with: [
                       html text: 'Some text: '.
                       html textInput on: #text of: self.

                       html button
                               onClick: (html javascript
                                       add: ((html jQuery id: dialogId) dialog open);
                                       add: (JSStream on: 'return false');
                                       yourself);
                               callback: [ self halt. "I'm not expecting this to be executed" ];
                               with: 'Accept' ]

Thanks,
Esteban_______________________________________________
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

default-action.st (2K) Download Attachment