JQTouch: transferring data between "views"

Hi, I played with jqtouch today, and I'm just wondering how to manage the data.

I tried to look back, but could not see a lot of documentation.

If I had a list of links for pronounced products? And I click on one, I can move on to the presentation of the product. How to pass variables, how would you have a variable $_GETto select a THAT product?

Or even if I set the link identifier to the record identifier and use JS to capture the identifier and somehow pass it to the following view?

Any help with this would be greatly appreciated!

NOTE. I also want to use it with a standalone extension, so I'm not sure if get ajax will work

Hi,

Billy

+3
source share
2 answers

You can watch the demo to see how it forms the view, i.e. AJAX> POST form example. Essentially, you create a jQT-style form and submit button:

<form id="ajax_demo" action="ajax_demo.php" method="POST" class="form">
  ...
  <a class="submit whiteButton" href="#">Submit</a>
</form>

Then on your receipt page (i.e. ajax_demo.php) you can access the form fields, for example. PHP $_GETor JavaScript location.search.

Another way is to save the data in the DOM using jQuery:

// in global level
$('body').data('ajax_demo', "some data for the page");

// in page/view level
$('#ajax_demo').data('key', 'value');
0
source

You can use the referrer property for a data object. The link will look like this:

<a href="#view" id="1">Product #1</a>

where the HTML id will match the product id. Then, in the "pageAnimationEnd" event, you can get the product data as follows:

$('#view').bind('pageAnimationEnd', function (e, info) {
  // get the id of the calling href
  var id = $(this).data('referrer')[0].id;

  $.getJSON('/products/' + id, function (data) {
    // do something with the data
  });
});
+4
source

All Articles