输入click不会触发JQuery对话框打开

时间:2016-01-06 16:43:37

标签: javascript jquery html

我和一些同事对这个问题感到有些困惑。我们在Javascript中有一个onclick事件,它打开一个JQuery对话框。当您实际单击指定按钮时,此方法有效。但是,当您按Enter键时,它将触发onclick事件并执行其他所需的功能。但是当它到达对话框时,它不会打开。奇怪的是,如果在对话框代码之前插入警报,它将打开警报,然后打开对话框。任何修复?

JQuery的:

$(document).ready(function () {
    $('#applyFilter').click(function () {
        console.log('event triggered');
        var suppString = $('#FK_SupplierID').val();
        var carryOn = true;
        //if the supplier ID fields is showing and populated:
        //check if supplier ID values are all numeric, if not show message and modal form
        if (suppString != null) {
            suppString.split(",").forEach(function (item) {
                if (item != '') {
                    if (!isInt(item)) {
                        //invalid value - set carryOn to false and exit the loop
                        carryOn = false;
                        return false;
                    }
                }
            });

            if (!carryOn) {
                alert("The Supplier ID field must only have a whole number, or a comma-separated list of whole numbers.  Please type in a valid value or click the ellipsis button to select the required suppliers from the supplier list.")
                return false;
            } else {
                //check if supplier label is populated - if not, populate it
                if (suppString != '' && $('#suppliersShown').text() == '') {

                    //GetSupplierNames
                    $.getJSON("./GetSupplierNames", { ids: suppString },
                            function (data) {
                                $('#suppliersShown').text("Supplier(s):" + data);
                                $('#suppliersShown').show();
                            }
                        );
                }
            }
        }

        $('#dialog-processing').dialog({
            closeOnEscape: false,
            //open: function (event, ui) {
            //    $(".ui-dialog-titlebar-close").hide();
            //},
            autoOpen: false,
            width: 400,
            resizable: false,
            modal: true
        });

        $('#dialog-processing').dialog('open');

        var table = $('#invoiceTable').on('processing.dt', function (e, settings, processing) {

            //    $('#dialog-processing').dialog('close');

        }

).DataTable({
    retrieve: true,
});
        table.ajax.url('./FilterData/?filterString=' + FilterParams()).load(function (json) { console.log(json); });

    });
});able({
                retrieve: true,
            });
            table.ajax.url('./FilterData/?filterString=' + FilterParams()).load(function (json) { console.log(json); });

});

HTML:

<button id="applyFilter">click</button>

0 个答案:

没有答案