从对话框调用函数时出现is not a function
错误
从对话框点击按钮:
Add: {
class: 'calendareventleft',
text: 'Add',
click: function() {
var title = $("#title").val();
var description = $("#description").val();
var otherinfor = $("#otherinfo").val();
$(this).ajaxcall(title, description, otherinfor);
}
}
按钮显示对话框
$('#button').click(function() {
$("#dialog").dialog({
title: "qwe"
});
$("#dialog").html("<div>" + "<form>" + "Title:<br>" + "<input type='text' id='title' class='calendarinput'>" + "<br>" + "Description:<br>" + "<textarea id='description' class='calendarinput calendartxtarea'></textarea>" + "<br>" + "Additional Information:<br>" + "<textarea id='otherinfo' class='calendarinput calendartxtarea'></textarea>" + "</form>" + "</div>");
$("#dialog")
.dialog("open");
})
我需要运行的功能
function ajaxcall(title, description, otherinformation) {
consoole.log(title);
consoole.log(description);
consoole.log(otherinformation);
}
答案 0 :(得分:2)
您正在调用$(this).ajaxcall(....)
,期望ajaxcall
成为插件方法,但这不是错误的原因。
只需将其称为
即可ajaxcall(title, description, otherinfor);
演示:Fiddle