Editor, select field, can I do onchange=submit ?

Editor, select field, can I do onchange=submit ?

ve7tccve7tcc Posts: 25Questions: 8Answers: 0

For inline editing, if I have a field which is a type='select' (dropdown menu type)
can I get it so that a new selection triggers a submit?

I tried onblur, did not trigger unless I click on another column.

Answers

  • ve7tccve7tcc Posts: 25Questions: 8Answers: 0

    The same goes for datetime fields, in inline editing, can you have onchange = submit()

    Go to this example, https://editor.datatables.net/examples/inline-editing/simple.html
    and inline, change a date. It does not trigger an update. How can I do that?
    I have to hit return on that example to save my change.

  • ve7tccve7tcc Posts: 25Questions: 8Answers: 0

    Some progress with this. But it affects primary and bubble editing too. I am not sure how to get it to only work on inline editing. I am sure this is not the optimal way to do this either. I figure doing similar for datetime fields should work.

                editor.on( 'open', function ( e, json, data ) {
                    $( editor.node('field_name')).on( 'change', function ( e, json, data ) {
                        if( editor.field('field_name').val() !=
                                editor.field('field_name').s.opts._lastSet ) {
                            editor.submit();
                        }
                    });
                } );
    
  • ve7tccve7tcc Posts: 25Questions: 8Answers: 0

    I worked out I can use the condition:

    editor.s.displayed == "inline"
    

    to confirm it is inline.

  • allanallan Posts: 63,773Questions: 1Answers: 10,511 Site admin

    Something like this should do the job:

    editor.field( 'myField' ).input().on( 'change', function () {
      editor.submit();
    } );
    

    Note - I would very strongly recommend against using the private s object in any way. It is considered to be internal to Editor and its properties can, will and do change between versions.

    Regards,
    Allan

  • ve7tccve7tcc Posts: 25Questions: 8Answers: 0

    Thank you, I will try this.
    Is there a method to replace the editor.s.displayed == "inline" bit?

  • ve7tccve7tcc Posts: 25Questions: 8Answers: 0

    the on change did not work for the datetime field, are there events for the date picker I can try?

    Thanks!

This discussion has been closed.