Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery / jqtouch getJSON call causing infinite loop?
    primarykey
    data
    text
    <p>Writing my first JQTouch app. When I go from <code>#login</code> to <code>#home</code>, a JSON ajax call happens successfully but the <code>pageAnimationEnded</code> event appears to be in an infinite loop. </p> <pre><code> $(function(){ $('#login').ajaxComplete(function (e, xhr, settings) { jQT.goTo('#home', 'flip'); }); $('#home').bind('pageAnimationEnd', function(e, info){ alert('animation ended'); //infinite loop happens in here $.getJSON('/test', function(data) { alert('json: ' + data); //this returns data successfully }); }); }); </code></pre> <p>Login POST call which JQuery intercepts and turns into AJAX:</p> <pre><code> &lt;div id="login" class="current"&gt; &lt;div class="toolbar"&gt; &lt;h1&gt;testapp&lt;/h1&gt; &lt;a class="button slideup" id="infoButton" href="#about"&gt;About&lt;/a&gt; &lt;/div&gt; &lt;form:form commandName="user" action="/login/authenticate"&gt; &lt;ul class="edit rounded"&gt; &lt;li&gt;&lt;form:input path="email"/&gt;&lt;/li&gt; &lt;li&gt;&lt;form:password path="password" /&gt;&lt;/li&gt; &lt;li&gt;Remember Me&lt;span class="toggle"&gt;&lt;input type="checkbox" /&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;a style="margin:0 10px;color:rgba(0,0,0,.9)" href="" class="submit whiteButton"&gt;Login&lt;/a&gt; &lt;/form:form&gt; &lt;/div&gt; </code></pre> <p>Any hints would be appreciated, thanks in advance! :-)</p> <p><strong>UPDATE</strong></p> <p>Apparently .ajaxComplete recieves events for other elements as well. I added a guard to filter the event that I want:</p> <pre><code> $(document).ready(function(e){ alert('document ready'); $('#login').ajaxComplete(function (e, xhr, settings) { if(settings.url == '/login/authenticate') { //add check to prevent infinite loop alert('jqt goto ' + settings.url); jQT.goTo('#home', 'flip'); } }); $('#home').bind('pageAnimationEnd', function(e, info){ alert('animation ended'); $.getJSON('/test', function(data) { alert('json: ' + data); }); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload