Reputation: 15301
I am creating an application by jQuery Mobile.
I want a link, which redirects to a page. for example:
<a href="/Account/" data-transition="turn" class="useroptions">Account</a>
It is available on all of pages, and I want to change href
of that link on every page to something like this:
<a href="/Account/?returnUrl=http%3A%2F%2Fexample.com%2FAbout" data-transition="turn" class="useroptions">Account</a>
I have written this code, but it is not working when jQuery Mobile loads a page with Ajax navigation:
$(function () {
$(".useroptions").attr("href", "/Account/?returnUrl=" + encodeURIComponent(document.URL));
});
How to do that when every page is shown? (Which event should I use? ...)
Upvotes: 0
Views: 3272
Reputation: 15301
I should use pageshow
event of jQuery Mobile. see pageshow
part of this page.
Modified version of jQuery code to work correctly:
$("div[data-role='page']").live("pageshow",function() {
$(".useroptions").attr("href", "/Account/?returnUrl=" + encodeURIComponent(document.URL));
});
Upvotes: 1