ecc ecc - 1 year ago 124
HTML Question

Select2 strips all attributes from <option>

I'm using select2 on my

tag, There is some additional when the user changes the selected option. and it makes use of attributes that I set as
for instance. Select2 seems to be striping all attributes from the
tags except for the

How can I disable this behavior or how can I get the data values some other way?

Edit: I forgot to add that I'm also using Sonata admin. Sonata is the one loading select2 by default.

ecc ecc
Answer Source

Turns out select2 was set to use remote data so my option elements were being replaced. I set my data attributes in the AJAX callback function and now everything works.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download