2013-05-02 59 views
1

我正在開發MVC應用程序。 我正在使用CSS的bootstrp。如何閱讀引導確認確定/取消事件?

我正在使用警報/對話框進行確認刪除記錄。 ,但對如何閱讀用戶的確定或取消的響應感到困惑。

var href = $(this).attr('href'); 
     if (!$('#dataConfirmModal').length) { 
      $('body').append('<div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h6 id="dataConfirmLabel">Deactivation Confirmation</h6></div><div class="modal-body">Are you sure to deactive @Model.Name ? </div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button><a class="btn btn-primary" id="dataConfirmOK">OK</a></div></div>'); 
     } 
     $('#dataConfirmModal').find('.modal-body').text($(this).attr('data-confirm')); 
     $('#dataConfirmOK').attr('href', href); 
     $('#dataConfirmModal').modal({show:true}); 
     return false; 

回答

0

你試過bootboxjs它採用引導的方式

我會給你一個示例代碼:

bootbox.confirm("Are you sure?", function(result) { 
    if (result) 
    { 
     Example.show("You press Ok"); 
    } 
    else 
    { 
     Example.show("You press Cancel"); 
    } 
}); 
0

就個人而言,我使用點擊每個模式按鈕事件進行我想要的行動。

我不認爲有模式發送的結果,我們可以在其他語言中看到。