page 1: get Google API lat & long; (dialog) link to page 2 (loaded via Ajax)
page 2: PUT to 'foobar' URL; 'foobar' server method will redirect back to page 1
*now, back in page1, the Google API lat & long don't get loaded anymore
I approached this issues from 2 sides:
1. Tried to see why the Google API lat & long loading event is not fired. I tried putting it in many different events: pageshow, pageinit, ready, etc. Nothing worked after the redirect from 'foobar' happened. I abandoned this one, even though I would be curious why it doesn't work.
2. When 'foobar' redirects to page 1, I tried to fully reload page 1, so that it will reload the Google API lat & long. So, in page 2, the link to 'foobar' had 'data-ajax' = false. To my surprise that didn't work. I suspect that page 1 is still loaded through Ajax. I added a 'data-url' tag to page 1, but that didn't do anything... mostly because I don't understand how 'data-url' is supposed to work.
I was able to make it work by adding 'data-ajax' = false and target='_self' to the link from page 2 to 'foobar'. But I really hate that I don't understand why 'data-ajax' = false by itself doesn't work.
I apologize for the long explanation, but did anyone come across this?
I'm really hoping there's some Rails developers perusing this forum. I did ask this question on the Google Rails Talk group last week but I received no answer, and I've been stuck for more than a week...
I'm trying to update a div on a page with an Ajax call and it doesn't work. If I call jquery directly from the browser (no Ajax), the div does get updated. However, if I call it through a remote call, the div remains unchanged. A remote call in Rails makes an Ajax call back to the server, which pushes back the following content: $('.mydiv').html('world');. Nothing happens to mydiv.
I'm a backend developer and I don't understand jquery that well, let alone jquery mobile. I tried adding .page() and .trigger('create') like I've found on some posts, but that didn't do anything. Also, I made sure that the cache tag was not used.
Thanks,
Jenna
PS. Here's my code:
<div data-role="content">
<div class="content-primary">
<div class="mydiv">something</div>
<div><a href="#" onclick="$('.mydiv').html('hello');">click</a></div> <!-- this works -->
<div><%= link_to foobar_url, :remote => true, :method => :put, 'data-ajax' => 'false' do %>click<% end %></div> <!-- this doesn't-->
</div>
</div>
def foobar
respond_to do |format|
format.mobile { render :layout => false }
end
end
$('.mydiv').html('world'); // in foobar.mobile.erb
I'm trying to implement a simple back button with jqm and I can't quite get there. I'm not sure if it is a jqm issue or a mobile browser issue. I'm not using external or data-ajax=false, so I'm using the default Ajax linking. I implemented a basic back button using data-rel='back'. Unfortunately when I click back, instead of using the cached version of the previous page, Safari (iOS 5+) tries to recreate the previous page. I thought mobile browsers should do a lot of caching, but it seems to me there is no caching done whatsoever. It wasn't just my iPhone. I tried it on an Android, and same thing. So, if mobile browsers don't do caching, then what's the point of jqm's back functionality?
Btw, I realized that I need to describe my setup in detail:
1. User is on Home page and clicks Search.
2. A POST action takes the user to the results page where there are links to result items.
3. User clicks a result item link (a GET action) which opens an item details page.
4. User clicks 'back' button from the details page to the results page. Instead of seeing the results page, the browser tries to do a GET on the results page - which is not correct. The results page is dynamically generated by POSTing something to it (from the Home page).
God... that's so much detail. I know it is a lot to read, but I don't know how to describe it any simpler.