我有以下代码:
var wait = 500;
$(document).on("click",".new_game_list_row",function(event){
var self = $(this);
//As the element clicked on has it's data attributes defined
//Retrieves it when the element is clicked on
var id_quiz_list = self.data('quizlistId'),
difficult = self.data('difficult');
userid = $("#new_game_list_wrap").data('userid');
setTimeout(function(){
$.post("new_game_add.php","userid="+userid+"&id_quiz_list="+id_quiz_list+"&difficult="+difficult,function(data){
$answer = data;
$("#new_game_list_wrap").fadeOut("slow",function(){
self.remove();
$("#quiz_list_wrap").append('<div class="quiz_list_row" data-quizlist-id="'+id_quiz_list+'" data-quizlevel-reached="0" '+
'><div class="inline list_cell" id="quiz_list_cell_rownew_id1">Quiz '+id_quiz_list+'</div><div '+
'class="inline list_cell" id="quiz_list_cell_rownew_id2">Current level: 1</div>');
showtrick(id_quiz_list,1);
});
}, "html");
}, wait);
});
我试图用来setTimeout()
避免在行上多次点击。我的桌子上满是幽灵条目。
我尝试过延迟,但没有奏效。
任何的想法?