Jquery 如何在每次单击时首先显示加载,然后再显示内容
我有一个四链接菜单(home | about | solutions | contact),使用jquery滚动技术,每次点击{Flesler's scrollTo code:}和{TKYK history plugin}。好的,我的情况是,当我单击第二个链接“about”时,它首先显示home,而不是setTimeout(),然后它显示正确的内容。是否仍然需要隐藏以前的内容并显示某种类型的“加载”,然后显示新内容 以下是我的init.js代码: }));Jquery 如何在每次单击时首先显示加载,然后再显示内容,jquery,Jquery,我有一个四链接菜单(home | about | solutions | contact),使用jquery滚动技术,每次点击{Flesler's scrollTo code:}和{TKYK history plugin}。好的,我的情况是,当我单击第二个链接“about”时,它首先显示home,而不是setTimeout(),然后它显示正确的内容。是否仍然需要隐藏以前的内容并显示某种类型的“加载”,然后显示新内容 以下是我的init.js代码: })); 我不确定这个问题,但我认为这将帮助您
我不确定这个问题,但我认为这将帮助您:
$('a.panel').click(function() {
$('a.panel').removeClass('selected');
$(this).addClass('selected');
$('a.panel').not($(this)).each(function() {
$($(this).attr("href")).hide();
});
// show your loading here
current = $(this);
$(current.attr("href")).show()
$('#container').scrollTo($(this).attr('href'),1000,{ easing:'easeInOutCubic',queue:true,duration:1500,axis:'xy', onAfter: function() { //hide your loading here } });
return false;
});
这包括隐藏菜单链接中的所有容器、显示装载、显示要显示的容器,然后隐藏装载
编辑:
也许你甚至不需要加载。。。只需从scrollTo选项中删除onAfter即可。BM感谢您的回复,但有一个小问题。当我实现您的代码时,滚动功能停止工作。另外,您在代码示例中说过“在此处显示您的加载”,现在您是在谈论这样的$(“#加载”).show();?
$('a.panel').click(function() {
$('a.panel').removeClass('selected');
$(this).addClass('selected');
$('a.panel').not($(this)).each(function() {
$($(this).attr("href")).hide();
});
// show your loading here
current = $(this);
$(current.attr("href")).show()
$('#container').scrollTo($(this).attr('href'),1000,{ easing:'easeInOutCubic',queue:true,duration:1500,axis:'xy', onAfter: function() { //hide your loading here } });
return false;
});