我正在開發MVC應用程序。我正在使用CSS的bootstrp。如何在點擊引導彈出按鈕時讀取響應?
我想在刪除記錄使用警報/對話框進行確認。 它應該要求確定/取消,並根據按鈕單擊下一個過程將被執行...
我已經從下面的代碼形式一些論壇,它工作正常,但沒有得到任何事件,如果我點擊在確定或取消按鈕
如何從閱讀下面的代碼這些點擊的事件?
$('#Deactivate').click(function() {
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"><h3>Are you sure to deactive @Model.Name ?</h3> </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});
$('#dataConfirmOK').on('click', function(e)
{
alert('@Model.Id');
var url2 = "@Html.Raw(Url.Action("DeactivateParty", "Party", new { @id = "PoNo"}))";
alert(url2);
url2 = url2.replace("PoNo", '@Model.Id');
$.post(url2, function (data) {
if(data == true)
{
var url = $("#RedirectTo").val();
location.href = url ;
}
});
return false;
});
感謝揚,我已經更新了我的問題。當我不在** dataConfirmOK **中放置任何代碼時,它完美的工作,但我把任何代碼放在OK按鈕上,然後它不工作...請檢查我更新的問題... – bnil 2013-05-03 07:42:40
@ user1650894:你的意思是什麼*它不工作* – Jan 2013-05-03 07:44:59
按鈕事件內部的代碼不工作...我已經把'alert('@ Model.Id');'來檢查光標是否進入該功能,但它不會來...是否我寫了什麼錯誤的代碼? – bnil 2013-05-03 07:49:55