我试图让JQueryUI 示例页面中的时间微调器在div 更改时更新它。我可以使标准微调器工作,但我无法弄清楚如何从微调器的修改时间版本访问事件。
这里有一个(不)工作小提琴:http: //jsfiddle.net/r5GYD/
$(document).ready(function () {
//I need this to be more widely available so it's declared out here
var time = 'time';
//check that the JQuery call actually does what it's supposed to
$('#time').html(time);
$.widget("ui.timespinner", $.ui.spinner, {
options: {
// seconds
step: 60 * 1000,
// hours
page: 60
},
_parse: function (value) {
if (typeof value === "string") {
// already a timestamp
if (Number(value) == value) {
return Number(value);
}
return +Globalize.parseDate(value);
}
return value;
},
_format: function (value) {
return Globalize.format(new Date(value), "t");
}
});
$("#timespinner").timespinner();
$("#timespinner").change(function () { //TODO not working :(
time = $(this).val();
console.log(time);
$('#time').html(time);
});
});
谢谢!