Below is the dynamicpage.js
script:
$(function() {
var newHash = "",
$mainContent = $("#main-content"),
$pageWrap = $("#page-wrap"),
baseHeight = 0,
$el;
$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();
$("nav").delegate("a", "click", function() {
window.location.hash = $(this).attr("href");
return false;
});
$(window).bind('hashchange', function(){
newHash = window.location.hash.substring(1);
if (newHash) {
$mainContent
.find("#guts")
.fadeOut(200, function() {
$mainContent.hide().load(newHash + " #guts", function() {
$mainContent.fadeIn(200, function() {
$pageWrap.animate({
height: baseHeight + $mainContent.height() + "px"
});
});
$("nav a").removeClass("current");
$("nav a[href="+newHash+"]").addClass("current");
});
});
};
});
$(window).trigger('hashchange');
});
The purpose of this code is to modify links from href="/staff"
to href="/#/staff"
for dynamic loading. However, this modification only occurs if the <a>
tag is wrapped in a <nav>
tag.
I attempted to specify ("#dynamic") in the jQuery/JavaScript and added id="dynamic" to the <a>
tag but it was not successful.
Is there a way to enable this functionality by simply adding id="dynamic" to the <a>
tag instead of enclosing each link with <nav>
?