javascript - setInterval / clearInterval Issue inside it's scope -


I have the following code, and it works fine until I suppress the #play button I assume it Because the var intID is set to another location and it is not in the same scope when i window.clearInterval () it ... how do i fix it? BTW, this is Google Maps API version 3

  function intervalstriggers () {return window.Sisthir (function () {placement ++; if (placements> gt; = markers. Lamps) {placement = 0;} Google.maps.event.trigger (Marker [placement], "click");}, 5000); }; Var intID = intervalTrigger (); Click on $ ('# Map_canvas') (function () {window.clearInterval (intID);}). $ ('A [href = # next marker]'). Live ('click', function () {placement ++; if (placements> gt; marker.lambi) {placement = 0}; google.maps.event.trigger (marker [place], "click"); Replacewith ('& lt; a href = "# play" & gt; play & lt; / a & gt;); Details are false. is;     }); $ ('A [href = # prevmarker]'). Live ('click', function () {placement--; if (placement == -1) {placement = markers.length-1} google.maps.event trigger (marker [placement], "click"); window Replacewith ('& lt; a href = "#play"> Play & lt; / a & gt;'); Details are false. is;     }); $ ('A [href = # play]'). Replacewith ('& lt; a href = "# paus" & gt; stop & lt; / a & gt;'); Live ('click', function () {$ ('a [href = # play]') ; Var intID = intervalTrigger (); return false;}); $ ('A [href = # pause]'). Live ('click', function () {window.clearInterval (intID); $ ('a [href = # pause]'). Replacewith ('& lt; a href = "#play"> Play & lt; / A & gt; '); returnback;}); Remove   

var from your # click handler following:

  $ ('a [href = # play]'). Live ('click', function () {$ ('a [href = # play]'). ('& Lt; a href = "# pause" & gt; stop & lt; / a & gt;'); IntID = interlibrar (); return back;});  

This will set the value of global var intID , so it is available for other event handlers.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -