2016-07-27 55 views
0

從網格中選擇多行,例如5條記錄。當我點擊一個按鈕(標題 - 分配)時,我想顯示第一個項目的消息框,並且必須執行分配功能並顯示成功消息。之後,顯示第二個項目的下一個消息框,並執行賦值和顯示成功消息的功能,並繼續完成上述過程以完成5個項目。但現在我的問題是:顯示消息問題

我有一個for循環,內循環messagebox函數那裏顯示消息。但它一次執行整個,只顯示一個消息框。我們正在顯示消息是在一個div中。

這是在循環中調用顯示消息框的函數。

$("#DwgEquipmentAssignBlock").on("click", function (e) 
{ 

    e.preventDefault(); 
    var totalSelectedIds=""; 
    var selectedcount = getWijGridSelectedRowCount("Grid1"); 
    if(selectedcount !=0) 
    {   

     for (var i = 0; i < selectedcount; i++) 
     {   
      var okReturn=showAlert("Select a Block to assign the selected Equipment"); 
      okReturn.okClick = function() 
      { 
       console.log('Value of i' + i); // I got only one console result as the count. (the total count) 
      } 

     } 

    } 
} 

顯示MessageBox函數:

function showAlert(msg) {//Messagebox with out grid page 

var showAlerObject = {}; 
showAlerObject.$dvMessageBox = $("#dvMessageBox"); 
showAlerObject.$dialogboxForMessage = $('#dialogboxForMessage'); 
showAlerObject.$dvMessageBox.html(msg); 
$(".ui-widget").css({ "font-weight": +"bold" }); 
showAlerObject.$dialogboxForMessage.dialog({ 
    title: 'Edu Plus', 
    showOnLoad: false, 
    autoExpand: false, 
    autoOpen: false, 
    width: 370, 
    modal: true, 
    close: function() { 

     showAlerObject.$dialogboxForMessage.dialog('destroy'); 
     showAlerObject.$dvMessageBox.html(''); 
    }, 
    buttons: { 

     OK: function() { 
      if (showAlerObject.okClick !== null) { 
       showAlerObject.okClick(); 
      } 
      showAlerObject.$dialogboxForMessage.dialog('destroy'); 
      showAlerObject.$dvMessageBox.html(''); 
     } 
    }, 
    show: 'fade', 
    hide: 'fade', 
    dialogClass: 'main-dialog-class' 
}); 
showAlerObject.$dialogboxForMessage.dialog("open"); 
return showAlerObject; 

}

回答

0

答:在確定:功能 - 首先破壞並清除HTML和繼續。這是我們需要實施的唯一改變。

function showAlert(msg) {//Messagebox with out grid page 
    var showAlerObject = {}; 
    showAlerObject.$dvMessageBox = $("#dvMessageBox"); 
    showAlerObject.$dialogboxForMessage = $('#dialogboxForMessage'); 
    showAlerObject.$dvMessageBox.html(msg); 
    $(".ui-widget").css({ "font-weight": +"bold" }); 
    showAlerObject.$dialogboxForMessage.dialog({ 
    title: 'Edu Plus', 
    showOnLoad: false, 
    autoExpand: false, 
    autoOpen: false, 
    width: 370, 
    modal: true, 
close: function() { 
    showAlerObject.$dialogboxForMessage.dialog('destroy'); 
    showAlerObject.$dvMessageBox.html(''); 
}, 
    buttons: { 
     OK: function() { 
      showAlerObject.$dialogboxForMessage.dialog('destroy'); 
      showAlerObject.$dvMessageBox.html(''); 
      if (showAlerObject.okClick !== null) { 
       showAlerObject.okClick(); 
      }     
     } 
    }, 
    show: 'fade', 
    hide: 'fade', 
    dialogClass: 'main-dialog-class' 
    }); 
    showAlerObject.$dialogboxForMessage.dialog("open"); 
    return showAlerObject; 
    }