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? ...)
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));
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.