當我想改變元素的內容,它工作正常無需影響,並執行此行爲與效果:如何防止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/。
非常感謝您的幫助!