我有一个输入字段,由硬件扫描程序填充。
我需要使用骨干来填充输入字段时触发更改事件,但不会发生模糊事件。是否可以使用骨干,或者只有在模糊事件发生后才会触发更改事件?
骨干事件声明:
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>
答案 0 :(得分:1)
骨干中的更改事件是Jquery事件。因此,如果您不希望触发器模糊应用更改,则可以在填充输入后直接触发更改事件:
$('selector').change();
$('selector').trigger("change");