Javascript OOP literal access variable inside method

<p>i have a problem accessing variable inside method in OOP.</p><p>this is my code :</p><pre><br /><code>var slideshow = {<br /><br /> elSet : $(".slideshow"),<br /> next : function() {<br /><br /> },<br /> swipe : function() {<br /> var clear = this.autorun().loop;<br /><br /> onSwipe(function() {<br /><br /> clearInterval(clear); // not working<br /> });<br /> },<br /> autorun : function() {<br /><br /> var self = this;<br /> var loop = setInterval(function() {<br /><br /> self.next();<br /><br /> }, 5000);<br /><br /> },<br /> initial : function() {<br /><br /> this.swipe();<br /> this.autorun();<br /> }<br /><br />}<br /><br />slideshow.initial();<br /></code><br /></pre><p>i want to clearInterval from <strong>variable loop</strong>,</p><p>on browser console return error TypeError: this.loop(...) is undefined</p><p>what's wrong with my code?</p><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34524831/javascript-oop-literal-access-variable-inside-method">http://ift.tt/1Jff4U9</a></h2>

Nhận xét

Bài đăng phổ biến từ blog này

Align div to bottom of the page in bootstrap

Align elements inside an tag vertically

Javascript is unable to stop page loading