Once I have opted into option 2, I am formatting text. It appears in formatted form I want to use later formatted text. However, when I use
$ ('# mySel'), select2 ('val') or $ ('# mysel'). Select2 ('data'). Text
These are the only original option text returned
My format: Result down function
Function format result (state) {if ( State.ID) Return State Text; // optgroup var result = "& lt; a style = 'color: heir; text-decoration: none;' Onclick = 'return myonclickevent (this);' Id = '' + state.id + "'class ='" + "ops" + "'> gt; + operator [state.id] +" ("+ state.text +") & lt; / A & gt; "; return result;}
I want to return the form" operator (option) "
When you call select2 ("data")
, you are retrieving the internal object, which is a copy of selection 2 data When you are calling select2 ("val")
, you are basically receiving the id
property of these objects, in most cases
You must take these objects and manually pass them to your formatting function if you want to use formatting work outside of Select2. Therefore, $ ("# mySel") Instead of calling "select2" ("data")
, you will call formatResults ($ ("# mySel") select2 ("data")) .>
Comments
Post a Comment