Initializing links in jqtouch in AJAX loaded content

Posted by Cody Caughlan on Stack Overflow See other posts from Stack Overflow or by Cody Caughlan
Published on 2010-06-01T04:47:47Z Indexed on 2010/06/01 4:53 UTC
Read the original article Hit count: 809

Filed under:
|
|

I have an iphone web app built in jqtouch, when content is loaded by links ("a" tags) then any content on the next page is parsed by jqtouch and any links are initialized. However, when I load content via an AJAX call and append() it to an element then any links in that content are NOT initialized by jqtouch. Thus any clicks on those links are full-blown clicks to a new resource and are not handled by jqtouch, so at that point you've effectively broken out of jqtouch.

My AJAX code is:

#data
<script type="text/javascript">
      $.ajax({
        url: '/mobile/nearby-accounts',
        type: 'GET',
        dataType: 'html',
        data: {lat: lat, lng: lng},
        success: function(html) {
          $('#data').empty().append(html);
          // Is there some method I call on jqtouch to have any links in $('#data') be hooked up to the jqtouch lifecycle?
        }
</script>

Thanks in advance.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about iphone-web