我使用 jquery.address() 通过 ajax 加载我的页面:
$.address.state('').init(function() {
// Initializes the plugin
$('#menu a').address();
$('#nextprev a').address();
}).change(function(event) {
// Loads the page content and inserts it into the content area
$.ajax({
url: $.address.state() + event.path,
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest.responseText);
},
success: function(data, textStatus, XMLHttpRequest) {
$('title').html($('title', data).html());
$.address.title(/>([^<]*)<\/title/.exec(data)[1]);
$('#content').html($('#content', data).html());
loadstuff();
startAnimation();
}
});
var startAnimation = function(data) {
... some animation going on here
});
目前代码调用ajax加载下一页后,通过startAnimation()飞入下一页。到目前为止,这真的很好。
但是我在#nextprev 中有一个#next 和一个#prev 元素。我要地址找出它们中的哪一个被点击,然后加载不同的函数(即startAnimation2())。