dependent

dependent

crush123crush123 Posts: 417Questions: 126Answers: 18
edited November 2015 in Editor

i have a couple of date fields, eventdatefrom and eventdateto

what i would like to do is set the value of eventdateto to the same as eventdatefrom, when eventdatefrom is being updated.

This, together with some validation, will help prevent the user setting an end date before the start date.

I have been trying to use

 editor.dependent( 'tblevent.EventType', function ( val ) {

 alert(val);

 }

but the event doesn't seen to be triggered from a text input, only from a select

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Answer ✓

    dependent() will be triggered by the change event by default (which simply typing into a text input does not trigger - although it should when the focus then leaves that input).

    You can have it listen for other events using the event option in the options parameter that you can pass to it (so for example you could listen for keyup). See dependent() for details.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited November 2015

    the fields are date fields which use the datepicker, so i wasn't seeing anything happen at first as i wasn't using the keyboard. !

    i can get the result i want now, but not when i want.

    the mouse events below will work, but if i try to use the change event, nothing happens

    editor.dependent( 'tblevent.EventDate', function ( val ) {
            editor.field( 'tblevent.EventDateTo' ).val( val );
        },
        {event: 'mouseup focusout'}
        );
    
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    What date picker specifically - datetime, or a plug-in? Can you link to the page?

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    I am using the datetime field from editor 1.5.2.

    i will post a link tomorrow

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    I've just been looking into this and figured out what was happening. I've got a fix which will be in 1.5.3 (which should be out tomorrow, all being well!). If you want to apply it immediately, in the Editor file search for the function _writeOutput - you will find the following block of code:

    this.dom.input
    .val( out )
    .focus();

    Replace with:

            this.dom.input
                .val( out )
                .change()
                .focus();
    

    That will trigger the dependent method with a regular change event.

    Thanks for letting me know about this issue.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited November 2015

    I am having a couple of problems with the editor (1.5.3) datetimefield

    ..will start a new thread as original question has been answered.

This discussion has been closed.