Selectize.js: reinitialize with dynamic content from ajax

Created on 6 Mar 2016  路  7Comments  路  Source: selectize/selectize.js

Hi, and thanks for this lovely plugin ;)

I'm wondering if there is a better way to use selectize on new "select" elements created using Ajax. i currenty do this:

$.ajax({
    url: "/fine.php",
    success: function(result) {
        $("#container").html('<p>' + result + '</p>');
        $("#container select.selectize").selectize();
    }
});

Thanks

question

Most helpful comment

maybe you can use "not selector"

$("#container select.selectize").not('.selectized').selectize()

All 7 comments

I think u can use jquery.load() , it can execute your script .
So u can put "$("#container select.selectize").selectize(); " in your ajax page.

see http://api.jquery.com/load/

Thanks pigochu for your reply.
I already use $("#container select.selectize").selectize(); so i was wondering if there is a better way to reinitialise selectize

maybe you can use "not selector"

$("#container select.selectize").not('.selectized').selectize()

I will close this as this doesn't seem to be exactly an issue with Selectize, but feel free to update as to the solution to your problem.

Hi Joallard,

Well, i'm still looking for a great solution to my need... :D
At the same time, I'd also love to know how i can tell if a "select" element is selectized, do you know how to?

@Redani What happened with @pigochu's solution, did it work?

I already use his solution, but I was wondering if there is an option to simply or reinitialize the specific select element!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CarlosLlongo picture CarlosLlongo  路  18Comments

brianreavis picture brianreavis  路  66Comments

Wardrop picture Wardrop  路  19Comments

Trevald picture Trevald  路  14Comments

nepsdotin picture nepsdotin  路  15Comments