我有一个输入字段被硬件扫描器填充。触发骨干变化事件,无模糊/输入字段丢失焦点
当填充输入字段,但没有发生模糊事件时,我需要骨干来触发更改事件。这是可能的骨干,或者只有在模糊事件发生后才会触发更改事件?
骨干活动宣言:
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>
这不是清楚我什么是问题。您的“硬件扫描仪”不会触发所有预期的事件,也不会触发您不想要的事件。 [X/Y问题](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem):为什么你想避免模糊?请添加一些“_hardware_ scanner”与您的浏览器交互的信息:例如它是否像一些条形码扫描仪一样模拟键盘? –
hardward扫描器像paste一样填充输入字段,但没有按键事件。它不会模糊输入框,并且我需要在扫描后立即处理到达输入字段的数据,因此无法使用更改事件,因为它只会在模糊时触发。 –
我明白了。有一个“更改”事件,但也可能是因为不完整的字符串。这是真的?您可以添加扫描仪可以填充任何虚拟数据的另一个字段吗?你可以使用这个chnage来检测填充其他字段是否完成。 –