开发者

Simple JQTouch question about creating dynamic links to content

开发者 https://www.devze.com 2023-01-18 03:07 出处:网络
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 da

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 w开发者_JS百科orld, 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消