我正在尝试从$(document).ready
块内显示一个bootbox。
这显示正常,直到我将调用函数的行放在$(this)
块中。
什么阻止这种工作的想法?
我有以下代码:
$(document).ready(function()
{
var getID = '#removeEntryCourses';
$(this).on('click', getID, function ()
{
bootDialogSuccess('<h2>Are you sure?</h2>', 'Are you sure you want to delete this course?<br/>This cannot be undone.');
});
//bootDialogSuccess('<h2>Are you sure?</h2>', 'Are you sure you want to delete this course?<br/>This cannot be undone.');
//When this line is uncommented and the $(this) block is removed there is no issue.
});
function bootDialogSuccess(title, message)
{
bootbox.dialog
({
message: message,
title: title,
buttons:
{
success:
{
label: "OK",
className: "btn-success",
callback: function()
{
alert('hello');
//removeCourse(total);
}
}
}
});
}
答案 0 :(得分:0)
因此,在函数调用之后问题的罪魁祸首是return false
。
$(this).on('click', getID, function ()
{
bootDialogSuccess('<h2>Are you sure?</h2>', 'Are you sure you want to delete this course?<br/>This cannot be undone.');
return false;
});
但是我不确定为什么当jsfiddle在评论中发布时这不会导致问题。