Inline Editor and type = 'select' fields
Inline Editor and type = 'select' fields
I'm trying to use a super basic select field with two values 'A' and 'D' with the inline editor.
{
label: "Statut",
name: "statut",
type: "select",
options: [
{ label: "A", value: "A" },
{ label: "D", value: "D" }
]
}
I would like that either (or both) selecting a value AND/OR pressing the return key trigger a submit event. I'm not fussy!
I've searched and the closest that I have come to a solution was with this post:
https://datatables.net/forums/discussion/22754/im-looking-for-an-example-of-using-an-inline-select
Specifically Allan's reply stating that there's no way to distinguish between the expected return key behaviors. That was a 2014 post and I was wondering if in 2016 there's a solution to achieve that seemingly simple goal?
I've found other more recent posts that I've found are not exactly related to this situation.
I've tried the 'onReturn' and 'submitOnblur' options with no success. The ideal option would be sound like 'onSelect' = 'submit' or submitOnselect = 'true'
// Activate an inline edit for ENTETE on click of a table cell
$('#entete').on( 'click', 'tbody td:not(:first-child)', function (e) {
entEditor.inline( this, {
submit: 'all'//, //Submit all information even if not changed
//onReturn: 'submit',
//submitOnBlur: true
} );
} );
BTW, everything works fine in the bubble editor.
Thanks in advance.
This question has an accepted answers - jump to answer
Answers
Hi,
Currently there isn't a better way to do this I'm afraid. However, the plan is to address this with 1.6 which will rework how Editor handles the return key, passing the responsibility of doing so to each field type plug-in. I think (hope!) that this might allow me to write some code specific to
select
elements that will allow this to work as expected. To be honest, I don't yet know if it will, but I have hopes that it will!Allan
Thanks for your reply Allan,
Leaving aside the return key, can the action of selecting a value using the 'select' control by itself be used as a trigger for a submit?
I'm using the selectize plug-in for another field and it does work in both forms of editors. I can always fall back on the selectize method but since this particular 'select' has only two possible choices, it seemed overkill.
Thanks.
JF.
Sure - use
field().input()
to get theselect
element and then just use a jQuerychange
event handler that will callsubmit()
.Allan
Thank you for your time Allan.