Object doesn't support property or method 'Deferred'

186 views Asked by At

I have implemented a javascript confirmation dialog. The dialog will open onClientClick event:

   <asp:Button ID="btnIssuerRemove" runat="server" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
        CausesValidation="false" CommandName="Remove" Text="Remove" OnCommand="issuerCommand_Click" OnClientClick="return ValidateBinExists()"/>

When button is clicked it should open a dialog with "OK" and "Cancel" butotns:

function ValidateBinExists() {
    if ($('#cphBody_gvBins').find("input[value='Edit']").length > 0 || $('#cphBody_gvBins').find("input[value='Update']").length > 0) {
        ShowDialog().then(function (answer) {
            console.log(answer);
            return answer;
        });

    }
}

function ShowDialog() {

    var defer = $.Deferred();
    $("#dialogBox").dialog({
       title: "System Message",
       modal: true,
       resizable: false,
       width: 250,
       buttons: {
           "Cancel": function () {
               defer.resolve(false);
               $(this).dialog('close');
           },
           "OK": function () {
               defer.resolve(true);
               $(this).dialog('close');
           }
        }
   });

    return defer.promise();
}

However, when clicking the button, nothing happens because I have a javascript error:

Object doesn't support property or method 'Deferred'

How can I fix that?

0

There are 0 answers