Reputation: 6197
My JQM includes three data-role="page"
.
The issue:
Now I go to another page2 from the default home page1, so the URL is localhost/index.php#page2
. When I refresh the page, it is still in page2.
Is that a way that it can go back to localhost/index.php
instead of current page (without any parameters)?
Upvotes: 1
Views: 3031
Reputation: 31732
To disable updating URL with #hashtag
, change default of changePage
which handles pages transition before loading jQuery Mobile script in <head>
.
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).on("mobileinit", function(){
$.mobile.changePage.defaults.changeHash = false;
});
</script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
Upvotes: 2
Reputation: 11371
Adding to @Omar's excellent answer, you could disable the changeHash
option when you're traversing from #page1
to #page2
, if you want this feature to be limited to only that point. Use changePage
like this :
$.mobile.changePage("#page2", { transition: "slideup", changeHash: false });
Upvotes: 1
Reputation: 10454
Each click event of the link / button fire the following...
To only remove the value, not the hash
window.location.hash = ""
...............................................................
This will completely remove the hash and value.
window.location.href = window.location.href.substr(0, window.location.href.indexOf('#'))
** Implementation **
$('a').click(function() {
window.location.href = window.location.href.substr(0, window.location.href.indexOf('#'));
});
Upvotes: 2