materialize icon indicating copy to clipboard operation
materialize copied to clipboard

Attaching change event to Select element!

Open ajrehman opened this issue 11 years ago • 3 comments

Unless I use the "browser default" class on the SELECT element, there is no way to attach a Jquery "Change" event to the materialized select element. Since the dropdown creates its own little span and it's a UL list of options rather than actual SELECT element options, it doesn't work, any idea how to accomplish that? Does the selector have those capabilities?

ajrehman avatar Jan 08 '15 00:01 ajrehman

Just use onchange on the original element On Jan 7, 2015 7:58 PM, "ajrehman" [email protected] wrote:

Unless I use the "browser default" class on the SELECT element, there is no way to attach a Jquery "Change" event to the materialized select element. Since the dropdown creates its own little span and it's a UL list of options rather than actual SELECT element options, it doesn't work, any idea how to accomplish that? Does the selector have those capabilities?

— Reply to this email directly or view it on GitHub https://github.com/Dogfalo/materialize/issues/419.

Dogfalo avatar Jan 08 '15 01:01 Dogfalo

It does work, thank you! My confusion was that, I was attaching a jquery change event to it which usually works for default SELECT elements but not for this one, for example:

$("#select-element").on("change", function(e) { .. });

Did not work, but instead if I added the "onchange" in place of the jquery "change" event like you mentioned:

Then it worked. I wondery why?

But thanks either way!

ajrehman avatar Jan 09 '15 05:01 ajrehman

See #369 which should allow both to work now.

Dogfalo avatar Jan 09 '15 12:01 Dogfalo