[英]Change event on Timepicker works in JS Fiddle, not in production/development environments
I have a simple timepicker
element like this: 我有一个像这样的简单timepicker
元素:
<input class="pickuptime_end" id="pickuptime_end" name="pickuptime_end" placeholder="Time" size="10" type="text" value="10 pm" style="display: inline-block;">
I'm just testing that on change of the value, it alerts me: 我只是在改变价值时进行测试,它提醒我:
$("input.pickuptime_start, input.pickuptime_end, input.deliverytime_start, input.deliverytime_end").change( function() {
alert("changed")
})
In the JS Fiddle everything works fine ( https://jsfiddle.net/gnroaxut/1/ ). 在JS Fiddle中一切正常( https://jsfiddle.net/gnroaxut/1/ )。
In my live site however ( https://hidden-tundra-8656.herokuapp.com/orders/61862e?key=UDIS ), it does not. 但是在我的实际网站( https://hidden-tundra-8656.herokuapp.com/orders/61862e?key=UDIS )中却没有。 The code is the exact same: 代码完全相同:
Rendered HTML: 呈现的HTML:
<input class="pickuptime_end" id="pickuptime_end" name="pickuptime_end" placeholder="Time" size="10" type="text" value="5 am">
Source JS code: 源JS代码:
$('.pickuptime_end').timepicker({
interval: 30,
disableTextInput: true
});
$("input.pickuptime_start, input.pickuptime_end, input.deliverytime_start, input.deliverytime_end").change( function() {
alert("changed")
})
Any thoughts as to why it's not working? 有什么想法,为什么它不工作? Note that: 注意:
The jsfiddle you linked was using a different version of timepicker than the one you are using on your site (1.10.0 [jsfiddle] vs 1.3.1 [your site]). 您链接的jsfiddle使用的是不同版本的时间戳,而不是您在网站上使用的时间戳(1.10.0 [jsfiddle] vs 1.3.1 [your site])。 Updating the jsfiddle with 1.3.1 breaks the alert: https://jsfiddle.net/ux2LweLb/2/ 用1.3.1更新jsfiddle打破警报: https ://jsfiddle.net/ux2LweLb/2/
However, using 1.3.1 lets you use the native change property of the timepicker: 但是,使用1.3.1可以使用timepicker的native change属性:
$('.pickuptime_end').timepicker({
interval: 60,
change: function(x){alert('changed')}
});
See: https://jsfiddle.net/t986738k/ for a working example. 有关工作示例,请参阅: https : //jsfiddle.net/t986738k/ 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.