Created
April 11, 2015 12:16
-
-
Save oclockvn/aea6d6d790a4092a9248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(document).ready(function () { | |
$('.btn-add').click(function (e) { | |
/* | |
* hủy liên kết | |
* | |
* việc này quan trọng | |
* nếu không hủy liên kết, modal sẽ không được load đúng cách | |
* vì action sẽ trả về 1 trang html trống với partialview | |
* | |
* cách tương tự return false; cách này thực hiện ở cuối method | |
*/ | |
e.preventDefault(); | |
var $modal = $('#myModal'); | |
var $modalDialog = $('.modal-dialog'); | |
var href = $(this).prop('href'); | |
// không cho phép tắt modal khi click bên ngoài modal | |
var option = { backdrop: 'static' }; | |
// kiểm tra (logic, điều kiện...) | |
// load modal | |
$modalDialog.load(href, function () { | |
$modal.modal(option, 'show'); | |
}); | |
}); | |
}); // document ready | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment