retrieve select field label
retrieve select field label
Hi
I am trying to retrieve the label of a select field initialize like
editor.add( {
type: 'select',
label: 'Locations:',
name: 'locations',
multiple: false,
separator: ',',
options: [
{ label: 'Edinburgh', value: 51 },
{ label: 'London', value: 76 }
// etc
]
} );
There is no problem with the
editor.field("locations").val();
witch return the value selected for the field name locations
I would like to retrieve the label of that selected field but
editor.field("locations").label();
return
"locations:<div data-dte-e="msg-label" class="DTE_Label_Info"></div>"
thanks in advance
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Did you manage to solve this issue in a nice way? Currently, I am having the same problem and I can't see a nice way around it, except stripping everything after the first '<' from the string.
I found a better way: use
editor.field(...).s.opts.label
. It would be nice if the input options were accessible via afield(...).options()
function.You would use
editor.field( 'myField' ).input().find( 'option:selected' ).text()
. This is based on thefield().input()
field returning theselect
element and then just use a little jQuery to get it.You should never use the
s
property - it is not documented and is considered private. It's internal parameter, can, will and do change between versions.Allan