So, i have this code which retrieves php files for me and id love to get jquery history plugin workin with this ( [URL=”http://tkyk.github.com/jquery-history-plugin/”]Jquery history plugin
[B]
Id be very gratefull if someone would help me out with this one.
All related code can be found bellow (the ones that should be needed anyways):
This is the code that retrieves php files inside “#content” when item from “#menu li a” with the specified id is clicked
[CODE]
$(document).ready(function(){
//References
var change = $(“#menu li a”);
var loading = $(“#loading”);
var content = $(“#content”);
//Manage click events
change.click(function(){
//show the loading bar
showLoading();
//load selected section
if(this.id == “home”)
{
change.load(this.className=’current-page’);
content.slideUp();
content.load(“pages/index.php”, hideLoading);
content.slideDown();
}
else if(this.id == “tokasivu”)
{
change.load(this.className=’current-page’);
content.slideUp();
content.load(“pages/secondpage.php”, hideLoading);
content.slideDown();
}
else
{
//hide loading bar if there is no selected section
hideLoading();
}
});
//show loading bar
function showLoading(){
loading
.css({visibility:”visible”})
.css({opacity:”1″})
.css({display:”block”})
;
}
//hide loading bar
function hideLoading(){
loading.fadeTo(1000, 0);
};
});
Heres the structure of the menu/content
[CODE]
<ul id=”menu”>
<li><a id=”home” class=”normal” href=”#Home”></a></li>
<li><a id=”secondpage” class=”normal” href=”#Secondpage”></a></li>
</ul>
<div id=”content”>
<ul id=”sec-menu”>
<li><a id=”link1″ class=”normal” href=”#”>Link1</a></li>
<li><a id=”link2″ class=”normal” href=”#”>Link2</a></li>
</ul>
</div>
Heres the code that jquery history plugin uses in demo for ajax
[CODE]
jQuery(document).ready(function($) {
function load(num) {
$(‘#content’).load(num +”.html”);
}
$.history.init(function(url) {
load(url == “” ? “1” : url);
});
$(‘#ajax-links a’).live(‘click’, function(e) {
var url = $(this).attr(‘href’);
url = url.replace(/^.*#/, ”);
$.history.load(url);
return false;
});
});