当我想改变元素的内容,它工作正常无需影响,并执行此行为与效果:如何防止jQuery在隐藏元素之前加载修改后的内容?
- 改变内容到新的
- 确实隐藏作用,对新的内容
- 确实放映效果,还会对新的内容
这里是每次推出的代码,我需要改变的内容:
function changePage(slug) {
var content = $('#content');
var title = $('#name');
$.getJSON('http://'+location.host+'/'+slug+'.json', function(data) {
$('#main').fadeOut('slow');
title.html(data.name);
content.html(data.content);
$('#main').fadeIn('slow');
});
}
这里是运行这个函数的代码:
var app = new Sammy.Application(function() {with(this){
get('#/', function() { with(this) {
changePage('_home');
}});
get('#/:page', function() { with(this) {
changePage(params['page']);
}});
}});
$(function(){app.run();});
这是萨米,http://github.com/quirkey/sammy/。
非常感谢您的帮助!