问题
I am using Jquery Address and everything seems to work fine except when I try to load the url in another tab or if I try to refresh. I've been working on this all day and was wondering if someone could tell me what I'm doing wrong.
Im loading pages like this...
<script src="/js/jquery.address-1.5.min.js"></script>
Here is my js...
var init = true, state = window.history.pushState !== undefined;
$.address.crawlable(true).state('/index').init(function() {
$('.alink').address();
}).change(function(event) {
var value = $.address.state() + event.path;
var ua = value.split("/");
// Selects the proper navigation link
$('.alink').each(function() {
if ($(this).attr('href') == value) {
$(this).addClass('selected');
$(this).children().addClass('navActive');
} else {
$(this).removeClass('selected');
$(this).children().removeClass('navActive');
}
});
if (state && init) {
init = false;
} else {
// Loads and populates the page data
$.ajax({
cache: false,
url: "/scripts/pages.php",
type: "post",
data: {action: ua[2]},
success: function(data){
$('title').html(ua[2]);
$('.content').html(data);
}
});
}
});
Here is the html...
<div id="nav" class="nav">
<div id="linkwrap">
<a href="/index"><div id="navHome" class="link">home</div></a>
<a href="/index/gallery" class="alink"><div id="navGallery" class="link">gallery</div></a>
<a href="/index/woods" class="alink"><div id="navWood" class="link">wood guide</div></a>
<a href="/index/styles" class="alink"><div id="navStyles" class="link">cabinet styles</div></a>
<a href="/index/products" class="alink"><div id="navProducts" class="link">products</div></a>
<a href="/index/contact" class="alink"><div id="navContact" class="link">contact</div></a>
</div>
</div>
Thank you in advance for all your time and help.
EDIT
Here is my site http://hw.weightlossexp.com here is an address that should work http://hw.weightlossexp.com/index/gallary
来源:https://stackoverflow.com/questions/19578306/jquery-address-is-not-working-on-refresh