Confirm Delete Modal/dialog Does Not Work When Using Within Partial View
Case 1: When clicking on the Delete 1 button the Bootstrap's modal dialog pops up and when you click on the Delete button of that popup, jquery code below, as expected, correctly w
Solution 1:
The problem is that you are using @section inside PartialView which will never work by design.
Work around: change from
@sectionScripts{
<script>
$(document).ready(function () {
$('#DeleteBtnParentID').on('click', '#DeleteBtnID', function (event) {
console.log('Test: ' + $(this).attr('value'));
});
$('#myModal').on('show.bs.modal', function (e) {
var btnValue = $(e.relatedTarget).attr('value');
$('#DeleteBtnID').attr('value', btnValue);
})
});
</script>
}
to
<script>
$(document).ready(function () {
$('#DeleteBtnParentID').on('click', '#DeleteBtnID', function (event) {
console.log('Test: ' + $(this).attr('value'));
});
$('#myModal').on('show.bs.modal', function (e) {
var btnValue = $(e.relatedTarget).attr('value');
$('#DeleteBtnID').attr('value', btnValue);
})
});
</script>
For more information you can check this question: Injecting content into specific sections from a partial view ASP.NET MVC 3 with Razor View Engine
Post a Comment for "Confirm Delete Modal/dialog Does Not Work When Using Within Partial View"