Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get selectize.js original element

I'm using selectize.js something like this:

$( 'select' ).selectize( {
    onChange: function( value ) {
        // how to get original element here?
    }
} );

There's several select elements on the page.
I want to get select on which the event occurred inside of onChange.
How can I do it?

like image 434
Legotin Avatar asked Nov 08 '25 17:11

Legotin


1 Answers

you can use $(this)[0] inside the onChange. Once this is the selectize object by itself

$( 'select' ).selectize( {
    onChange: function( value ) {
      var obj = $(this)[0];
      alert(obj.$input["0"].id);
    }
} );

Here's a Fiddle

like image 82
andrepaulo Avatar answered Nov 10 '25 07:11

andrepaulo