[Seaside] Anchor double click problematic

Esteban A. Maringolo emaringolo at gmail.com
Mon Mar 26 17:05:16 UTC 2018


You should set the new onClick handler after the first one is triggered.

It is, once clicked, you set a new handler that basically is an dummy handler.

html anchor
       id: idAjaxAnchor;
       onClick:(html jQuery script: [:script |
           script << (JSStream on: ''this.onclick = function(){ return
false; }').
           script << (html jQuery ajax callback: [
flagDialog := false.
                              [self setupVoceAttiva: each] on:
DTRDataBaseLockError do: [:ex | flagDialog := true] ] ];
                                onSuccess: ( html jQuery ajax
                                                        script: [ :s |
flagDialog ifTrue:[  s << (s  jQuery: #'dialogId') dialog open ])
                               ]);
       with: [ self render6Item: each on: html ].

(code untested)

This might prevent a double callback invocation, but keep in mind that
protecting this from the client side is brittle, some mobile browsers
might submit a request twice if it timeouts, so the robust way of
achieving this is to have some sort of server side protection.

I wonder if somebody already implemented a callback that can be
activated only once or returns an error otherwise.

Regards,

Esteban A. Maringolo


2018-03-26 13:15 GMT-03:00 dtrussardi at tiscali.it <dtrussardi at tiscali.it>:
> Ciao,
>
> in the seaside 3.1 application i have a classic anchor declaration:
>
>
> html anchor callback:[  delta :=  self doSomethingWithJQDialogError  ];
> with: [html image url: DTRFileLibrary / #greenupGif ; altText: 'Incrementa';
> title:'Incrementa' ]
>
> But if the user doubleClick on the anchor i have some problematic and the
> dialog is not right display.
>
> The double click and the relative double callback generated some
> problematic.
>
>
> Double click isn't a problem you handle at the server, it's something you
> handle at the client. Toss a touch of JavaScript on the onClick of the
> anchor and your problem is solved. One click and the anchor is disabled from
> future clicks while it's submitting.
>
> html anchor
>  callback:[  delta :=  self doSomethingWithJQDialogError  ];
>  onClick: 'this.onclick = function(){ return false; }';
>  with: [html image url:  DTRFileLibrary / #greenupGif ;
> altText: 'Incrementa';
> title:'Incrementa' ]
>
> --
> Ramon Leon
>
>
> Now as Leon suggested ( thanks ) i add the :   onClick: 'this.onclick =
> function(){ return false; }';
>
> and all work right with callback re-rendering.
>
>
> But with the ajax callback as :
>
> html anchor
>       id: idAjaxAnchor;
> onClick: 'this.onclick = function(){ return false; }';
>        onClick:( html jQuery ajax callback: [ flagDialog := false.
>  [self setupVoceAttiva: each] on: DTRDataBaseLockError do: [:ex | flagDialog
> := true] ] ];
>                onSuccess:
>                    ( html jQuery ajax
>                        script: [ :s | flagDialog ifTrue:[  s << (s  jQuery:
> #'dialogId') dialog open ]);
>
> with: [ self render6Item: each on: html ].
>
> the anchor is not rendering after the first click and the click is disabled
> for always.
>
> I can disabled the click only for some time ( one second )?
>
> Any trick to solve the problem?
>
> Thanks,
>
> Dario
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>


More information about the seaside mailing list