views:

498

answers:

2

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.

A: 

I was able to achieve this by doing two things:

1) Exporting the previously private method "liveTap" as public by modifying jqtouch.js and adding liveTap to the list of methods returned (at the end of jqtouch.js):

publicObj {getOrientation:getOrientation,goBack:goBack,goTo:goTo,
 addAnimation:addAnimation,submitForm:submitForm, liveTap:liveTap};
return publicObj;

2) Calling the liveTap handler on my wrapped container which has the links I would like to "hook up" to jqTouch:

      $('#data a').click(function(e) {
        e.preventDefault();
        jqTouch.liveTap(e);            
      });
Cody Caughlan
A: 

Doing the following worked better for me and it didn't require modifying the source:

jQT.goTo('#slide', 'slide');

where #slide is the ID of the panel to slide to.

emtrane