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' ]
All works fine when the user click on the anchor. If the method doSomethingWithJQDialogError found a error display a relative dialog using the code: masterView jqDialog:(( WADTRGenericErrorManagement openOnException: ex onModel: aModel ) alert:true ) where jqDialog is: jqDialog: aComponent ^ self wait: [ :cc |
self
show: aComponent onAnswer: cc delegation: (JQDialogDecorator new delegate: aComponent; yourself). WARenderNotification signal ] 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. How i can disabled the callback entry after the first ? I do some test with:
But the "asynchronous callbacks" create the problematic like above. I do some test with the onClick
This intercept the single click, but how i can display the dialog after the callback if it return a wrong value? Thanks for considerations, Dario _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Try JQEvent new preventDefault In your onclick callback. It will cancel all subsequent event handling. Joachim
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by dtrussardi@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.
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 :
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 [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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 [hidden email] <[hidden email]>: > 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 > [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 |
Ciao, thanks.
> You should set the new onClick handler after the first one is triggered. What do you mean? > It is, once clicked, you set a new handler that basically is an dummy handler. What should I do to set up a new 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) I render the anchor code following your code ( at least I think so ) but after the first click the anchor click is disabled for forever. Many thanks for your help. Dario > > 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 [hidden email] <[hidden email]>: >> 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 >> [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 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |