I have the following javascript code:
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();
}
}
]});
}
When I run from the consul delete_draft(6, "this is it")
I get this error
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
How can I fix this? The website for Noty is http://needim.github.com/noty/ If you think it should work, comment.
A TypeError: "x" is not a function occurs when a function is called on an object that does not contain the called function. When calling a built-in function that expects a callback function argument, which does not exist. When the called function is within a scope that is not accessible.
This is a standard JavaScript error when trying to call a function before it is defined. This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the expression did not return a function object.
You may experience the “jQuery is not defined error” when jQuery is included but not loaded. Make sure that it's loaded by finding the script source and pasting the URL in a new browser or tab. The snippet of text you should look for to find the URL to test.
I have just come across this problem. It turns out to be because the variable name noty
is the same as the exported function name noty
.
var n = noty({text: 'testing 123'});
Simply changing the variable name fixes it for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With