Javascript Smoothstate.js:阻止重新加载标题,尽管这些链接会触发页面更改
要求触发ajax调用的链接位于包含要更新内容的#main div中。但是,我需要在内容交换中省略头部和内部的链接,最好只在指定的.content div中重新加载内容 使用smoothstate.js是否有任何方法可以防止头链接被重新加载,尽管要求它们位于刷新的#main div中 我想把contentdiv与onReady函数中返回的$newContent对象分开。然而,尽管我能够分离出指定的div,但将返回的对象传递到html失败Javascript Smoothstate.js:阻止重新加载标题,尽管这些链接会触发页面更改,javascript,jquery,ajax,smoothstate.js,Javascript,Jquery,Ajax,Smoothstate.js,要求触发ajax调用的链接位于包含要更新内容的#main div中。但是,我需要在内容交换中省略头部和内部的链接,最好只在指定的.content div中重新加载内容 使用smoothstate.js是否有任何方法可以防止头链接被重新加载,尽管要求它们位于刷新的#main div中 我想把contentdiv与onReady函数中返回的$newContent对象分开。然而,尽管我能够分离出指定的div,但将返回的对象传递到html失败 (function header_init() {
(function header_init() {
$('#main').smoothState({
anchors: 'a',
blacklist: '.no-ajax',
prefetch: true,
cacheLength: 4,
repeatDelay: 500,
onStart: {
duration: 300,
render: function ($container) {
$('html').addClass('animate-page-out');
$('html').removeClass('animate-page-in');
}
},
onReady: {
duration: 300,
// `$container` is a `jQuery Object` of the current smoothState container
// `$newContent` is a `jQuery Object` of the HTML that should replace the existing container's HTML.
render: function ($container, $newContent) {
// Update the HTML on the page
var content = $($newContent).find('.main-content');
console.log($newContent);
console.log($(content));
// $container.html($newContent);
$('.main-content').html($(content));
}
},
onAfter: function ($container, $newContent) {
// after page loads, all scripts must be re-initialize to account for any new DOM items
$('html').addClass('animate-page-in');
$('html').removeClass('animate-page-out');
}
});
}());