[Seaside] form submit button and both onClick + callback

Cyril Ferlicot D. cyril.ferlicot at gmail.com
Sat Nov 12 13:57:57 UTC 2016


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
> seaside at lists.squeakfoundation.org
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20161112/44324f0f/attachment.sig>


More information about the seaside mailing list