Re: form submit button and both onClick + callback

"Cyril Ferlicot D." <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
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
> [email protected]
> 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
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
signature.asc (application/pgp-signature, 801 B)
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCAAGBQJYJx/pAAoJEBzpUtxBqUIDKrUP/R1ad1UdHNHMtb8Gqrvos1nU
tJFR1BVPoFUwncT2z9NDLoRra/JOMWXad+X/2BrCjohqpKuBn0OigmE4J5p7zNbz
ZwQzDIhRFC28S08U1qV5fFxVB7s4zkNBfvTUiXYZHQJAvXC+btq2EhD9On0D/i7e
xCt8wrEGv/n+KokJfzpDjk/+Fy0/EZE0fdZmcYm3R0182p7740wuWRDUoRF/bVzW
pYw+Ur05wewqtjcky3q23pXCeRVHbyIot/MAAsBABx/KExG7nxTugxxNKnhjcM+V
NFsBoOCylgHv1K34Y6BpuQZ4V+jDbi+gW32r5YLCA9IYL503y8XkZa48kp5DChJf
Rwuyb0eYxQKfr286i2bY5OHA/3zznTTTZu2qmUxrgO/SGwixAJ8DaBCjFeY9v3aP
RD7nPhLmo+OZOGtHTucCmVVc7AVDTqipKO7YPFzEuFUlKGxBXYIU0CMW0GXN5AFT
4BImwcsMyvq56sFXlCSVBLy25E09pjCRZ3oLfyw4zYa45SULUyeagS7pEvCN1/gJ
fQsYLQKAjr5IAIA6e2m6H2vj3NJpL6qa33Dir15MOyAnZ6RVoMJFJZ1ndqIiO7mF
ReQeNQ8/lgSaDX3HKfzpdhcHGKshrG7pXSAS6tJHVK4UsCDFNLYjgfBO+ofWABMo
NiAMmYH5HmRgZZlSjxc/
=WJ2/
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.