1

DEMO

Calling a function from dialog box is getting is not a function error

Button click from dialog:

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 showing the dialog

$('#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");
})

The function i need to run

function ajaxcall(title, description, otherinformation) {
 consoole.log(title);
 consoole.log(description);
 consoole.log(otherinformation);
}
asked Oct 31, 2015 at 3:50
0

1 Answer 1

2

You are calling $(this).ajaxcall(....) where it is expecting ajaxcall to be a plugin method, but it is not that is why the error.

Just call it like

ajaxcall(title, description, otherinfor);

Demo: Fiddle

answered Oct 31, 2015 at 4:10

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.