Thursday, 15 August 2013

javascript - Jquery callback function executes multiple times -


I have a popupdriver such as be sure to show as below

  & lt; Div class = 'pop' & gt; Me & lt; Span class = "spok" & gt; OK & lt; / Span & gt; & Lt; Span class = "spcancel" & gt; Cancel & lt; / Span & gt; & Lt; / Div & gt;  

Now this popup will open on some status, and when I click on the button I want to return some value to the original values ​​

I was able to call back the function But .... when I try to hide the popup, it is sometimes called as an alert. Select Yes or No in OK dropdown, click OK or Cancel, two or three times, you will see the effect

  Function ShowPop (Onclos) {$ ('. Pop'). ; $ (".spok"). Click (function () {onclose ('OK');}); $ (". Spcancel") (function () {onclose ('CANCEL'); $ ('pop'). Hide ();}); $ ("# Slt"). $ ("# Slt"). $ ("# Slt") {var retval = showpop (function (retval) {$ ('.pop'). == "yes") ImYes (); and emano ();}) done (function () {});}); $ (Document) .ready (function () {}); Function ImYes () {Warning ('I am Yes'); } Festival ImNo () {Warning ('I'm not'); }  

Find the full code here

< P> You click the showpop :

  $ (".spok") each time you call (function () {onclose ('OK') ;});   

This is obviously the result in many forms of alerts.

Do not do this:

  • Either make it a ready function.
  • Or check whether the handler is already set up or not.
  • Or remove handler after every use.

No comments:

Post a Comment