【发布时间】:2014-05-15 12:18:30
【问题描述】:
这是一个原型函数,我使用 noty 显示按钮确认。
function confirmation(message, call_func)
{
var m=noty(
{
text: message,
modal: true,
layout : 'center',
theme: 'notifications',
buttons: [
{
addClass: 'general-button red', text: 'Yes', onClick: function($noty)
{
call_func;
$noty.close();
}
},
{
addClass: 'general-button', text: 'No', onClick: function($noty)
{
$noty.close();
}
}]
});
return m;
}
我用语法调用这个函数,
confirmation("Are you sure want to delete this item?", "delete("+id+")");
因此,在单击“是”按钮时,必须调用另一个函数 delete(id)。但它没有,为什么?
我检查了警报,alert(call_func)。我以 delete(10) 发出警报,其中 10 是实例的 ID。
【问题讨论】:
-
试试这个 eval(call_func);而不仅仅是 call_func;
标签: javascript jquery noty