触发 backbone 更改事件而不模糊/失去对输入字段的关注

Trigger backbone change event without blur / lost focus on an input field

我有一个由硬件扫描仪填充的输入字段。

我需要 backbone 在填充输入字段时触发更改事件,但不会发生模糊事件。这对 backbone 是否可行,或者更改事件是否仅在模糊事件发生后触发?

Backbone 事件声明:

    events: {
        // On destination populate set destination and focus on location
        "change #destination" : "destinationscan",
        // On Location populate set location and focus on crate
        "change #location" : "locationscan",
        // On crate populate send data.
        "change #name" : "cratescan"
    },

HTML:

<input id="name" type="text" placeholder="Enter Crate Name..." required value="" />
            <div id="locationtaholder">
                <input type="text" placeholder="Type a location..." required id="location" /><img id="clearlocation" src="img/clear.png" alt="Clear Location" title="Clear Location" class="item-hidden" />
                <ul class="typeahead dropdown-menu"></ul>

            </div>
            <div id="destinationtaholder">
                <input type="text" placeholder="Type a destination..." id="destination" /><img id="cleardestination"   src="img/clear.png" alt="Clear Destination" title="Clear Destination" class="item-hidden" />
                <ul class="typeahead dropdown-menu"></ul>
            </div>

backbone中的变化事件是Jquery事件。因此,如果您不想触发模糊应用更改,您可以在填充输入后直接触发更改事件:

$('selector').change();
$('selector').trigger("change");