Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ui timepicker onChange Event

i am Struggling with onchange for JQuery ui timepicker plugin: http://trentrichardson.com/examples/timepicker/

I am using the following code.

$(document).ready(function ()
{
    $('#CutoffTime').timepicker({ stepMinute: 15 });
});

// Trying to catch the change event

$(function ()
{
    $('#CutoffTime').change(function ()
    {
        // do something heree
    });
});

// my HTML

<input type="text" id="CutoffTime" />

For some reason it seems to go in an infinite loop? is there a better way of achieving what i need?

like image 793
user1358918 Avatar asked Aug 03 '12 14:08

user1358918


People also ask

How to get timepicker value in jQuery?

Method 1: $('#datetimepicker4'). on('selectTime', function() { var time = $('#datetimepicker4'). timepicker('getTime'); alert(time); // this will be a Date object that includes the time });

How to set timepicker value in jQuery?

jquery-timepicker allows entering times via the keyboard. Setting forceRoundTime to true will round the entered time to the nearest option on the dropdown list.

How do I use Onchange in Datepicker?

To work with jQuery Datepicker onchange(), use the datepicker onSelect event. This will show which date we added currently and changed to.

How do I set Timepicker value?

You can set the default time via JavaScript : $('mySelector'). timepicker({defaultTime: '10:45 PM'});


1 Answers

If you look farther down the page they have an example that uses onselect

$('#CutoffTime').datetimepicker({
    stepMinute: 15,
    onSelect: function(dateText, inst){
        if(window.console)
            console.log(dateText);
    }
});
like image 121
grdaneault Avatar answered Oct 02 '22 17:10

grdaneault