jQWidgets Forums

jQuery UI Widgets Forums Editors DateTimeInput Cannot Set Time when value is initially NULL

This topic contains 4 replies, has 2 voices, and was last updated by  aoverton07 11 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • aoverton07
    Participant

    When using the jqxDateTimeInput I cannot set the time when the input is initially NULL. Here is my scenario, it can easily be reproduced:

    Init jqxDateTimeInput with value = NULL so input is initially EMPTY

    $("#dateTimeTest").jqxDateTimeInput({ theme: theme, width: '120px', height: '25px',formatString: 'hh:mm tt',showCalendarButton: false, theme: theme, allowNullDate: true, value: null});

    Set the time/date using either of the provided methods (val, setDate):

    $("#dateTimeTest").val(dateObject);

    OR

    $("#dateTimeTest").jqxDateTimeInput('setDate', dateObject);

    When this is done, no matter what date or time the object is holding, the input shows “12:00 AM“.

    If you try to set the time/date again (now that the input is showing 12:00 AM), it works!
    If you take out the “value: null” in the initialization of the dateTimeInput then this problem does not occur, but then all my time inputs show up as 12:00 AM.

    I have tried many different configurations to get this to work, and it seems to all be caused by the input initially being NULL. If the input is NULL, you CAN NOT set the date or time on the first attempt.

    Is this expected behavior? Please let me know if you are able to reproduce this…


    Peter Stoev
    Keymaster

    Hi aoverton07,

    Please, post a full sample which demonstrates your scenario.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    aoverton07
    Participant
    $("#dateTimeTest").jqxDateTimeInput({ 
        theme: theme, 
        width: '120px', 
        height: '25px',
        formatString: 'hh:mm tt',
        showCalendarButton: false, 
        allowNullDate: true, 
        value: null});
    
    $("#testButton").on('click', function(){
    
        var dateObject = new Date();
    
        $("#dateTimeTest").val(dateObject);
    
        //or this
        //$("#dateTimeTest").jqxDateTimeInput('setDate', dateObject);
    }
    <input type="button" value="CLICK ME" id="testButton" >
    
    <div id="dateTimetest"></div>

    There you go, there’s your working example. Steps on how to reproduce:

    1. Click the button that says “CLICK ME”
    2. Notice that input was set to “12:00 AM”
    3. Click button again
    4. Notice that input is set to current local time


    Peter Stoev
    Keymaster

    Hi aoverton07,

    The Solution is:

    ` $(“#dateTimeTest”).jqxDateTimeInput({
    width: ‘120px’,
    height: ’25px’,
    formatString: ‘hh:mm tt’,
    showCalendarButton: false,
    allowNullDate: true
    });
    $(“#dateTimeTest”).jqxDateTimeInput(‘setDate’, null);
    $(“#testButton”).on(‘click’, function () {
    var dateObject = new Date();
    $(“#dateTimeTest”).val(dateObject);
    });`

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    aoverton07
    Participant

    Thanks Peter,

    This is a simple workaround that definitely works for now, but shouldn’t it work when setting the “value: null” in the initialization?

    Best Regards

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.