我有以下javascript代码:
function delete_draft(id, name) {
var text = 'Are you sure you want to delete "' + name + '"?';
alert(id + name)
var noty = noty({
text: text,
buttons: [
{addClass: 'btn btn-primary', text: 'Yes', onClick: function($noty) {
// this = button element
// $noty = $noty element
$noty.close();
$.post('/ajax/drafts/delete', {id:id}, function(data) {
document.location.reload(true);
});
}
},
{addClass: 'btn btn-danger', text: 'Cancel', onClick: function($noty) {
$noty.close();
}
}
]});
}当我从consul delete_draft(6, "this is it")运行时,我得到这个错误
TypeError: undefined is not a function
arguments: Array[1]
get message: function () { [native code] }
get stack: function () { [native code] }
set message: function () { [native code] }
set stack: function () { [native code] }
type: "called_non_callable"
__proto__: Error我该如何解决这个问题呢?Noty的网站是http://needim.github.com/noty/,如果你认为它应该工作,请评论。
发布于 2012-09-18 18:53:32
我刚刚遇到了这个问题。这是因为变量名noty与导出的函数名noty相同。
var n = noty({text: 'testing 123'});只需更改变量名就可以为我解决这个问题。
发布于 2012-09-21 06:27:44
除了重命名变量之外,还要确保包含布局js文件。缺省值是top,所以如果没有在选项中指定,则需要包含noty/layouts/top.js。如果您指定了任何其他布局,请包含相应的布局js文件。
https://stackoverflow.com/questions/11916261
复制相似问题