DataTables Editor DataTime Picker OnChange Event has no data.

DataTables Editor DataTime Picker OnChange Event has no data.

washuit-iammwashuit-iamm Posts: 84Questions: 32Answers: 1

Hello, regarding new $.fn.DataTable.Editor.DateTime() I noticed that the selected date is actually a property on the instance.

This is making some plugin development pretty difficult for us. The OnChange event has no arguments so we can not properly set up hoods with the Editor DateTime Field.

Can you please pass the selected date back when you internally call OnChange?

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    I had expected that in instances like this you would just read the value directly from the input element that you've assigned for the date time input.

    Valid point though - it should also be executed in the scope of the instance so you could do this.val(). Noted for the next release.

    Allan

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    @allan I will appreciate if you will pass another argument specifying the source element on which the DateTime was init (like that.dom.input)

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    That makes sense - thanks. I'll look into that as well.

    Allan

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    Thanks, another option could be to pass the value along with the arguments that are sent to the onChange, like this onChange: myFunctionName(event, someData)

    either way anything is welcome :smile:

  • Radoslav KonuchRadoslav Konuch Posts: 9Questions: 4Answers: 0

    Hey, this addition would really be appreciated ;)

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Hi,

    Little update on this - the next release of Editor will carry this change. DateTime picker's onChange callback will now execute in the scope of the date time instance and pass two arguments:

    1. The selected value (as a string) and
    2. The Date() object for the selected date / time.

    Allan

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    @allan Will it be possible to tell which dom element was the source of the event?

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    It wasn't without using the private parameters before, but I've just added a third parameter based on your suggestion - so it's now:

    1. The selected value (as a string) and
    2. The Date() object for the selected date / time.
    3. The input element that triggered this, wrapped by jQuery

    Allan

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    edited March 2019

    Thanks, that will be useful for integration

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    edited March 2019

    @allan unrelated to topic and feel free to delete (because I don't know how) but when doing edit and then save comment it duplicates it :s

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @daniel_r ,

    I think it's just a temporary wobbly - if you refresh the page I'm only seeing a single comment. Is that the case for you too?

    Cheers,

    Colin

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Yeah its really annoying that. It seems to be a bug in the forum software. A refresh of the page after an edit, as Colin says, is the workaround at the moment.

    Allan

This discussion has been closed.