문제

I've looked at many JQTouch tutorials but I haven't found a description on a simple thing:

Given a list of items, how do you turn each item into a link that then brings up a dynamic page showing data about that item?

Here is the flow I what I want to do:
1) Present list of items
2) Item is tapped
3) an XML call is made to the server with the ID of that item, and the associated data is returned
3) XML data is processed, and a new page is displayed with this information.

My problem is in Step #2, creating the link and passing the ID of the object I want to access - over to the $.ajax call in #3. All the tutorials have been either hard-coded list items (with associated DIVs) or using Submit for search. I understand how to make the AJAX call, I just can't get the ID of the item over to that call.

Example: I have a list of Venues, and I want to be able to click on an individual Venue and pull up that information. In the web world, my link would use RESTful routes (/venue/2) or I could use a parameter "?id=2".

But since JQTouch relies on "id" names for divs, how do I pass the dynamic ID number of the Venue as a link? I can access the XML at something like http://mysite.com/venues/2.xml to get ID #2 of a Venue.

Thanks for your help!

도움이 되었습니까?

해결책

So, you could link an anchor to some page:

<div id="home">
  <ul>
    <li><a href="http://mysite.com/venues/1">Venues 1</a></li>
    <li><a href="http://mysite.com/venues/2">Venues 2</a></li>
  </ul>
</div>

And http://mysite.com/venues/2 may be:

<div id="venues-2">
  <!-- page content -->
</div>

When the "Venues 2" is tapped, the page would be downloaded and inserted dynamically into the current document.

The official jQTouch demo contains some examples of how pages may be loaded dynamically (i.e. with AJAX) in jQTouch; tap into AJAX and note how pages are loaded.

I hope this would inspire you to come up with a solution for dynamic page ID.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top