groenroos / minimalect

Minimal select replacement for jQuery
350 stars 52 forks source link

Access to element during onChange callback #48

Closed patrickgalbraith closed 10 years ago

patrickgalbraith commented 10 years ago

It would be great to have access to either the select element or the minimalect instance during the onChange callback. Currently the scope of the callback is the settings object which means it isn't possible to know which select the callback is for.

Simple example:

$("select").minimalect({
   onchange: function(value, text) {
       this.element // undefined
   }
});

I've attached a pull request with the thisRef updated but you could also just pass the element reference through as an additional parameter.

groenroos commented 10 years ago

Good point! Merged. Will have to update the minified version once I have the time.

patrickgalbraith commented 10 years ago

Thanks ;)

Also might be worth looking to see if it make sense to update any of the other callbacks. I'll leave that up to your discretion since onchange is the only one I use.