Skip to content

Instantly share code, notes, and snippets.

@oclockvn
Created April 11, 2015 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oclockvn/aea6d6d790a4092a9248 to your computer and use it in GitHub Desktop.
Save oclockvn/aea6d6d790a4092a9248 to your computer and use it in GitHub Desktop.
<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