editor: select2 and focus
editor: select2 and focus

Hello,
I'd like to activate focus for a select2 editor field by opening it for creation of a new entry (but not when editing the entry) - so the onFocus option, which is set globally, is not suitable.
I tried this - without success:
editor.on( 'initCreate', function (e) {
editor.field( 'job_id' ).focus();
});
Any further ideas?
Thank you
Ole
This discussion has been closed.
Replies
The syntax you are using looks correct. You would need to post a test case.
You can try this - but it should be an equivalent of "initCreate":
and check the console of your browser please.
This event triggers the focus even later: after the form has been opened:
Thank you, @rf1234 - but this still does not work:
http://live.datatables.net/daqipade/1/edit
but it works with the "onFocus: 'focus'" option (but this will trigger the focus not just for the create action)
this does the trick:
thank you, @rf1234 for setting me on the right path
Glad you got it working. Select2 seems to behave differently than the Select or Selectize field types. With Selectize the field opens on focus - even if you don't want it to
. Had to set focus to null to make sure the dropdown didn't open on opening the form.