Reputation: 947
Someone know how to reset the jQuery Timepicker http://trentrichardson.com/examples/timepicker/ ? I need to set the Hours and the Minutes to 0 before open it up.
I tried to do that but it doesn't work:
$('#timepicker').timepicker({
hour:0, minute: 0});
I set the value of the bind textbox to empty but If I show the timepicker, it still have the previously value setted.
Thanks
Upvotes: 2
Views: 10144
Reputation: 1236
Find this $.datepicker._updateDatepicker = function(inst) addon.js file and add this code to clear input.
var buttonPane = $(this).datepicker("widget").find(".ui-datepicker-buttonpane");
$("<button type='button' class='ui-datepicker-clean ui-state-default ui-priority-primary ui-corner-all'>Clear</button>").appendTo(buttonPane).click(function(ev) {
inst.input.val('');
});
Upvotes: 0
Reputation: 1
Try this.
The solution is not good enough(Using some internal variables).
Works for me though.
[tong@localhost javascripts]$ cat jquery-ui-timepicker-clear-button.js
(function($){
var old_fn = $.datepicker._updateDatepicker;
$.datepicker._updateDatepicker = function(inst) {
old_fn.call(this, inst);
var buttonPane = $(this).datepicker("widget").find(".ui-datepicker-buttonpane");
$("<button type='button' class='ui-datepicker-clean ui-state-default ui-priority-primary ui-corner-all'>Clear</button>").appendTo(buttonPane).click(function(ev) {
inst.input.val('');
$(inst.settings.altField).val('');
});
}
})(jQuery);
Upvotes: 0
Reputation: 29932
I think you need to set alwaysSetTime
to false:
alwaysSetTime – Default: true - Always have a time set internally, even before user has chosen one.
From: http://trentrichardson.com/examples/timepicker/
Upvotes: 0
Reputation: 2523
Usually datepickers are associated to a textbox element. Try modifying the value of that element to have the date (usually today date) at 00:00.
Upvotes: 1