guradio
guradio

Reputation: 15565

calling function from dialog button jquery ui

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);
}

Upvotes: 1

Views: 235

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388446

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

Upvotes: 2

Related Questions