Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using $.mobile.changePage and passing data

I am trying to learn myself jQuery Mobile. I think it is really cool, but I am stuck at something. If I want to call this:

$j.mobile.changePage({ url: $j("#News"), data: "apple=banana", type: "GET"}, "slide", true, true);

It does not seem to work. I am not really known with passing data with jQuery, so mayby I am doing something wrong.

Kind regards, Senne

Edit: Sorry, put the wrong code up there...

like image 616
iSenne Avatar asked Nov 06 '22 05:11

iSenne


2 Answers

As far as I know - url must be a real url or an id of another div[data-role=page]

To clarify:

Providing an ID shows up another div that is avaliable in the current document (You can create html files with multiple pages in them).

Also - jquerymobile is loading a page only once, and adding it to the document for later reference. No server side actions will be triggered later. (I'm not sure how it handles the calls with data provided)

like image 178
naugtur Avatar answered Nov 12 '22 20:11

naugtur


Based on trial and error, this is what I see happening:

  • $.mobile.changePage('#'+id, filter, false, true) refreshes the current view but doesn't execute the request on the server
  • $.mobile.changePage({url:'#'+id, data:'code=apple=banana', type:'GET'}, 'slide', false, true) doesn't refresh the current view but does execute the request on the server
  • $.mobile.changePage({url:'http://localhost/SomeOtherPage.aspx', data:'code=apple=banana', type:'GET'}, 'slide', false, true) refreshes the current view and executes the request on the server

So it seems that the base URL must be different to update the current view while executing on the server.

like image 26
Nariman Avatar answered Nov 12 '22 18:11

Nariman