form submit button and both onClick + callback

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

form submit button and both onClick + callback

Petr Fischer
Hello,

I have simple submit button in my form, but I want both onClick (browser side javascript) and callback (server side smalltalk form submit code) to be called.

In the onClick, I want to just simply disable submit button (user can't click twice), like:

onClick: (JSStream on: '$("#submitButton").prop("disabled", "true");

But then (when onClick is defined), callback: is not executed.

Is it a bug? Any trick? Thanks! pf
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: form submit button and both onClick + callback

CyrilFerlicot
On 12/11/2016 05:22, Petr Fischer wrote:

> Hello,
>
> I have simple submit button in my form, but I want both onClick (browser side javascript) and callback (server side smalltalk form submit code) to be called.
>
> In the onClick, I want to just simply disable submit button (user can't click twice), like:
>
> onClick: (JSStream on: '$("#submitButton").prop("disabled", "true");
>
> But then (when onClick is defined), callback: is not executed.
>
> Is it a bug? Any trick? Thanks! pf
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
Hi!

The classic callback will refresh the page, so you do not want to use it
I guess because if you want the page to refresh, you don't need to
disable the button.

What you can do is:

myButton
  bePush; "You do not want a submit button since you do not want the
page to refresh"
  id: #myId;
  onClick: (html jQuery ajax
    callback: [ … ];
    onSuccess: (JSStream on: '$("#myId").prop("disabled", "true");');
        with: 'Submit'

Be careful, this will not activate the callbacks of your form. You can
do it this way:

myButton
  bePush;
  id: #myId;
  onClick: (html jQuery ajax
    seralizeForm;
    callback: [ … ];
    onSuccess: (JSStream on: '$("#myId").prop("disabled", "true"););
        with: 'Submit'

You also have the onComplete: and onError: methods depending of what you
wants.

I hope this help you :)

Have a good day!

--
Cyril Ferlicot

http://www.synectique.eu

2 rue Jacques Prévert 01,
59650 Villeneuve d'ascq France


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

signature.asc (817 bytes) Download Attachment