Chosen: $(".chzn-select").chosen is not a function

Created on 21 Aug 2011  ·  6Comments  ·  Source: harvesthq/chosen

Hi there,

I'm using the following code and unfortunately I can't get chosen to work..
jQuery(function($){ $('.chzn-select').chosen(); });

I've link the js files in the following sequence.

Jquery
chosen.jquery.min
all.js

But my firebug keeps saying " $(".chzn-select").chosen is not a function "

I really appreciate any help.

Thanks.

Most helpful comment

I was getting $(".chzn-select").chosen is not a function as well. Turned out to be a double loading of jQuery – I had test compiled the rails asset pipeline locally and it was loading jQuery from two places.

All 6 comments

jQuery(function($){ $('.chzn-select').chosen(); });

You should just have

$(".chzn-select").chosen();

Else

(function($) { $(".chzn-select").chosen(); })(jQuery);

Ensure that jQuery is loaded and use $(document).ready(

@andyscott12 the code jQuery(function($){...}); is exactly about doing something when the DOM is ready. It is the shortcut for the other syntax. And the error is not about jQuery but about chosen in the ticket.

@edukranz make sure Chosen is loaded correctly.

@edukranz Is the jQuery(function($){ $('.chzn-select').chosen(); }); line in all.js?

If you're still having trouble, re-open this issue and include a link to a demo -- we'll do our best to help you out.

@pfiller I had it inside the head tag. Well, I'm having another go at it, I'll keep you posted.

I was getting $(".chzn-select").chosen is not a function as well. Turned out to be a double loading of jQuery – I had test compiled the rails asset pipeline locally and it was loading jQuery from two places.

I had the same thing, but when I removed that line - it gave me different error:

$(...).foundation is not a function

The problem got fixed when I cleared the cache and cookies in my browser.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexfrancavilla picture alexfrancavilla  ·  9Comments

asvetlenko picture asvetlenko  ·  3Comments

jbrooksuk picture jbrooksuk  ·  6Comments

ali1360 picture ali1360  ·  5Comments

zerocrates picture zerocrates  ·  7Comments