Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery在数据加载期间显示/隐藏引导模式_Jquery_Twitter Bootstrap - Fatal编程技术网

jQuery在数据加载期间显示/隐藏引导模式

jQuery在数据加载期间显示/隐藏引导模式,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,当jQuery将数据重新刷新到我的几个div中(然后将其隐藏)时,我试图显示一条引导模式消息。数据正在刷新OK。但是,模式会立即打开和关闭 当我只使用一个简单的加载GIF图像而不是模式图像时,情况也是如此。不知道我做错了什么。在数据完全刷新之前,模式(或gif)需要保持不变 提前感谢您的帮助 JS代码: $('.container').on('click', '.markAttend', function(event, ui) { myApp.showPleaseWait(); //thi

当jQuery将数据重新刷新到我的几个div中(然后将其隐藏)时,我试图显示一条引导模式消息。数据正在刷新OK。但是,模式会立即打开和关闭

当我只使用一个简单的加载GIF图像而不是模式图像时,情况也是如此。不知道我做错了什么。在数据完全刷新之前,模式(或gif)需要保持不变

提前感谢您的帮助

JS代码:

$('.container').on('click', '.markAttend', function(event, ui) {
   myApp.showPleaseWait(); //this calls the modal to display
   event.preventDefault();
   var contactID =  $(this).attr('contactID');
   var eid = <?php echo $eid ?>;

   $.ajax({
      url: 'functions-ajax.php',
      type: 'post',
      data: 'action=markAttend&contactID=' + contactID + "&eid=" + eid, //send a value to make sure we want to destroy it.
      success: function(data){
         $("#searchlist").load(location.href + " #searchlist"); //Refresh list
         $("#attendanceTotal").load(location.href + " #attendanceTotal"); //Refresh list
         $("#searchinput").val(''); //clear out search input field
         myApp.hidePleaseWait(); //this calls the modal to hide
      }             
   });
 });
$('.container')。在('click','.markattent',函数(事件,用户界面){
myApp.showPleaseWait();//这将调用要显示的模式
event.preventDefault();
var contactID=$(this.attr('contactID');
var-eid=;
$.ajax({
url:'functions ajax.php',
键入:“post”,
数据:“action=markattent&contactID=”+contactID+“&eid=“+eid,//发送一个值以确保我们要销毁它。
成功:功能(数据){
$(“#搜索列表”).load(location.href+“#搜索列表”);//刷新列表
$(“#attendanceTotal”).load(location.href+“#attendanceTotal”);//刷新列表
$(“#searchinput”).val(“”);//清除搜索输入字段
myApp.hidePleaseWait();//这将调用要隐藏的模式
}             
});
});

好吧,您需要等待
load()
函数完成

为此,您需要添加如下回调:

$("#searchlist").load(location.href + " #searchlist", function(){
   myApp.hidePleaseWait();
});
但是,由于您有2个加载函数,因此需要一些更复杂的逻辑。试试这个:

$('.container').on('click', '.markAttend', function(event, ui) {
   myApp.showPleaseWait(); //this calls the modal to display
   event.preventDefault();
   var contactID =  $(this).attr('contactID');
   var eid = <?php echo $eid ?>;
   var counter = 0;

   $.ajax({
      url: 'functions-ajax.php',
      type: 'post',
      data: 'action=markAttend&contactID=' + contactID + "&eid=" + eid, //send a value to make sure we want to destroy it.
      success: function(data){
         $("#searchlist").load(location.href + " #searchlist", function(){ 
            counter++;
            if(counter === 2) myApp.hidePleaseWait(); //this calls the modal to hide
         }); //Refresh list
         $("#attendanceTotal").load(location.href + " #attendanceTotal", function(){ 
            counter++;
            if(counter === 2) myApp.hidePleaseWait(); //this calls the modal to hide
         }); 
         $("#searchinput").val(''); //clear out search input field

      }             
   });
 });
$('.container')。在('click','.markattent',函数(事件,用户界面){
myApp.showPleaseWait();//这将调用要显示的模式
event.preventDefault();
var contactID=$(this.attr('contactID');
var-eid=;
var计数器=0;
$.ajax({
url:'functions ajax.php',
键入:“post”,
数据:“action=markattent&contactID=”+contactID+“&eid=“+eid,//发送一个值以确保我们要销毁它。
成功:功能(数据){
$(“#搜索列表”).load(location.href+“#搜索列表”,function(){
计数器++;
if(counter==2)myApp.hidePleaseWait();//这将调用要隐藏的模式
});//刷新列表
$(“#attendanceTotal”).load(location.href+“#attendanceTotal”,function(){
计数器++;
if(counter==2)myApp.hidePleaseWait();//这将调用要隐藏的模式
}); 
$(“#searchinput”).val(“”);//清除搜索输入字段
}             
});
});

我无法测试它,所以让我知道你能在JSFIDLE上复制相同的吗,太好了!非常感谢你。