views:

121

answers:

1

Hello,

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!

A: 

So, you could link an anchor to some page:

<div id="home">
  <ul>
    <li><a href="http://mysite.com/venues/1"&gt;Venues 1</a></li>
    <li><a href="http://mysite.com/venues/2"&gt;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.

William
This answer helped, thanks. Down the road I'll go with a solution that is only sending XML over the wire, but for now its perfect. I had looked at the JQTouch demo before, but didn't see a relevant example. I'll look at the source code instead of just the demo.
beeudoublez
Why do you want to use XML over JSON? And, if this answer is helpful, perhaps you should cast a vote?
William
Re. demo, you should definitely look at the source, which is largely the purpose of the demo: let people learn by examples.
William