有什么语法,"正在加载..."在显示JSON数据之前淡入?现在,数据被隐藏,没有显示任何内容。
a1.start = function(hookElementSelection, dataurlForJsonFile) {
jQuery('<div/>', {
id: 'loading',
text: 'Loading...'
}).appendTo(hookElementSelection);
hookElementSelection.hide();
$("hookElementSelection.loading").fadeIn("fast");
//resetting data in case this isnt the first run through
a1.products = {};
a1.recipes = {};
a1.suppliers = {};
a1.bakedRecipes = [];
//make an ajax call and wait for success
$.ajax({url:dataurlForJsonFile}).success(function(data) {
//get the recipe data
parseJSONData(data);
//put the recipes on the page
$.each(a1.recipes, function(i, recipe) {
recipe.render(hookElementSelection);
});
renderCalculator(hookElementSelection); //add in the final calculation logic
});
};
答案 0 :(得分:0)
尝试更改hookElementSelection.hide(); $( “hookElementSelection.loading”)淡入( “快”)。到
hookElementSelection.children()不是( “#加载”)隐藏()。; 。hookElementSelection.find( “#加载”)淡入( “快”);
由于
答案 1 :(得分:0)
由于隐藏了hookElementSelection,因此更改其附加的元素可以正常工作。
jQuery('<div/>', {
id: 'loading',
text: 'Loading...'
}).appendTo($("body"));
$("#loading").fadeIn("slow");