Reputation: 2065
In my html I have such code: link and div for jQuery UI Dialog:
<a data-comment="delete" data-comment-url="<?=Yii::app()->createUrl('comments/delete', ['id' => $comment->id])?>" href="javascript:" ">
</a>
<!-- div with dialog's markup -->
<div id="commentDelete" class="modal smallDialog" title="УДАЛЕНИЕ">
Delete this row &
<a class="button142 wa" id="confirmDeleteComment" style="">Yes</a>
<a href="javascript:;" onClick="$('#commentDelete').dialog('close');" class="button142 wa">No</a>
</div>
In my external js-file I have event handler to catch the click on link:
$(document).on('click', '[data-comment="delete"]', function (evt) {
evt.preventDefault();
var data = $.data(document, 'comments'),
$this = $(this);
var options = {
title: 'Delete row?',
autoOpen: false,
resizable: false,
height: 200,
width: 380,
show: { effect: 'drop', direction: "up" },
modal: true,
draggable: true,
open: function (event, ui) {
},
close: function (event, ui) {
$("#commentDelete").dialog().dialog('close');
},
create: function(event, ui){
$('#confirmDeleteComment').click(function(){
console.log("!!!");
});
}
}
$("#commentDelete").dialog(options).dialog('open');
When I click on link, this event fires well, no problem. But I hope that inside function open()
I can assign my action to the first button of div, which used in UI Dialog. Tracing the code, I see that open()
fired, click-assigning passed well, without errors, but when I try to click on button - I have no action as I considered - no logs in console.
What am I doing wrong ?
Upvotes: 0
Views: 172
Reputation: 74420
You could delegate it to modal div
level:
$('#commentDelete').on('click', '#confirmDeleteComment', function () {
console.log("!!!");
});
Upvotes: 1