How get the option label from field Editor
How get the option label from field Editor
Hi all,
I use editor extension and i declared a field type select .
, {
label : 'Attribut',
name : 'attribut',
type : 'select',
options: [
{ label: "Ajouter", value: "add" },
{ label: "Enlever", value: "remove" }
]
},
},
i declared a event with the following code :
$('select', editorAddAttribut.node('attribut')).on('change', function (e) {
var attributObj = editorAddAttribut.get('attribut');
var input = editorAddAttribut.field('attribut');
console.log( "attributObj: ");
console.log( attributObj);
console.log( "input.get: ");
console.log( input.get());
setOptionList( editorAddAttribut.get('attribut'),'Codeunique','AttributValue' )
} );
Output :
attributObj:
add
Input.get:
add
I would like display the label instead the value but it doesn't work or i don't know how to do.
In my case i want to have following output "Ajouter" when i selected first option.
i try different syntax but nothing work.
Thank you for your help
Michel
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
I'm not too clear on the problem, but you can use
field().label()
to get the label for the field. If that doesn't help, could you link to your page please so we can take a look,Colin
Hi colin,
if i use field().label() i display the label of the field in my case "Attribut" but i want the label of the option selected and in my case this is the first in my example
{ label: "Ajouter", value: "add" },
and it should be "Ajouter"
and with event declared i use the code :
var input = editorAddAttribut.field('attribut');
and input.get() display the value "add' but not the label "Ajouter"
Hi again,
I see, you could try one of these two options here - the second would be best as making proper use of the API:
See example here: http://live.datatables.net/bimakubo/2/edit
Colin
Hi colin,
Thank you it is work fine.
thank you for your help.
have nice WE.