在空的搜索/文本框中按Enter键时,我什么也不会做

时间:2018-07-18 15:23:09

标签: javascript html knockout.js

我有一个带有search/text box的订单页面,可以在其中按产品名称或代码进行过滤。

我遇到的问题是,当您在空白的search/text box中按 Enter 时,什么都不会发生,而是弹出要订购模式框的添加项目。仅在使用Internet Explorer时会发生此问题。在Google Chrome浏览器中,一切正常运行。

我的代码:

<div class="input-group-addon"><span class="glyphicon glyphicon-search"></span></div>
  <input type="text" id="productFilter" class="form-control" placeholder="Filter by Product Name/Code" data-bind="textInput: productFilter">
</div>
<table id="orderContents" class="table table-condensed table-bordered">
  <tr>
    <!-- ko ifnot: enforceZeroQuantity -->
    <th style="width: 17%">
      <button class="btn btn-warning btn-xs pull-left hidden-print" data-bind="click: toggleAllLineQuantityVarianceInfo, disable: isBusy, visible: orderHasQuantityVariance, attr: {title: expandOrContractTitle()}">
        <span class="fa" data-bind="css: {'fa-expand' : isAllQuantityVarianceInfoCollapsed(), 'fa-compress' : !isAllQuantityVarianceInfoCollapsed()}"></span>
      </button>
      <span class="visible-xs pull-right">Qty</span><span class="hidden-xs pull-right">Quantity</span>
    </th>
    <!-- /ko -->
    <th>
      Product
      <!-- ko ifnot: isReadOnly()-->
      <button id="addOrderLine" class="btn btn-success btn-xs pull-right hidden-print" data-bind="click: addOrderLine, disable: isBusy, visible: canAddOrderLines() || canAddLinesToDispatchedOrder()" title="Click to add a line to this order">
        <span class="glyphicon glyphicon-plus"></span>
      </button>
      <button id="sortOrderLines" class="btn btn-info btn-xs pull-right hidden-print rightMargin" data-bind="click: toggleOrderLineSort, disable: isBusy, visible: canSortOrderLines" title="Click to sort the lines in this order">
        <span class="glyphicon glyphicon-sort"></span>
      </button>
      <button id="cancelSortOrder" class="btn btn-danger btn-xs pull-right hidden-print" data-bind="click: cancelOrderLineSort, disable: isBusy, visible: lineSortActive" title="Click to cancel the sort of the lines in this order">
        <span class="fa fa-remove"></span>
      </button>
      <button id="updateSortOrder" class="btn btn-success btn-xs pull-right hidden-print rightMargin" data-bind="click: updateLineSortOrders, disable: isBusy, visible: lineSortActive" title="Click to save the sort order">
        <span class="fa fa-save"></span>
      </button>

谁能看到错误在哪里?我只想在空白的搜索框中按 Enter ,但我什么也不想做,因此不应弹出将要添加到订单模式的项。

下面是添加订单模式的代码,没有表单标签

function addOrderLine() {
                if (viewModel.orderState() !== "Template" && viewModel.orderIsLocked()) {
                    dynamicModal.showModal({
                        viewModel: {
                            title: 'Add Item(s) to Order',
                            closeModal: function() {
                                this.modal.close();
                            }
                        },
                        template: "/Content/components/order/modals/order-locked-modal.html",
                        context: viewModel
                    });
                    return;
                }

0 个答案:

没有答案