-1
我有一個函數(模態確認)在外部JS文件中定義它返回一個值作爲這樣的:
function confirmation(question) {
var defer = $.Deferred();
$('<div></div>').html(question).dialog({
autoOpen: true,
modal: true,
title: 'Confirmation',
buttons: {
"Delete All Items": function() {
defer.resolve("true"); //this text 'true' can be anything. But for this usage, it should be true or false.
$(this).dialog("close");
},
"Cancel": function() {
defer.resolve("false"); //this text 'false' can be anything. But for this usage, it should be true or false.
$(this).dialog("close");
}
},
close: function() {
//$(this).remove();
$(this).dialog('destroy').remove()
}
});
}
現在,當我試圖調用$(document).ready(function() {
裏面的功能,我得到一個未捕獲引用錯誤
所有必需的文件有蜜蜂。包括在調用腳本中。我想明白爲什麼是這個以及我如何解決這個問題?
參考由它自己的錯誤並沒有任何意義。你可以打開開發工具並檢查錯誤發生的位置。 –
這個函數不會返回任何東西,它本身會創建一個documentfragment然後拋棄它,絕不會將該元素添加到dom中。 –
在屬性事件[未捕獲的ReferenceError - 函數未定義]中調用的函數(http://stackoverflow.com/questions/39668892/uncaught-referenceerror-function-is-not-defined)? 'defer'是從函數返回的嗎? – guest271314