I am using Virtuemart and enalbled a "Multi-Variant" options. It nearly works, in the sense that only sometimes the product page (which has the custom options dropdowns) gives a JavaScript error. Some other times it works as expected. I have never seen something giving an error ONLY sometimes, I am explaining it due to the fact that anothet JavaScript hasn't finieshed loading and doesn't give conflict...

The error is: jQuery(...).chosen is not a function

I Cannot show you the page because it' protected and under cnostruction, but I can show you the snipped of Javascipt giving the conflict...

< script id="updateChosen_js" type="text/javascript">//<![CDATA[ 
if (typeof Virtuemart === "undefined")
    var Virtuemart = {};
    Virtuemart.updateChosenDropdownLayout = function() {
        var vm2string = {editImage: 'edit image',select_all_text: 'Select all',select_some_options_text: 'Available for all'};
        jQuery(".vm-chzn-select").each( function () {
            var swidth = jQuery(this).css("width")+10;
            jQuery(this).chosen({enable_select_all: true,select_all_text : vm2string.select_all_text,select_some_options_text:vm2string.select_some_options_text,disable_search_threshold: 5, width: swidth});
    Virtuemart.updateChosenDropdownLayout(); //]]>
  • Please check this file is being loaded on the page: /media/jui/js/chosen.jquery.min.js
    – Lodder
    Aug 23 '16 at 14:39
  • yes it's loaded by VirtueMart: /components/com_virtuemart/assets/js/chosen.jquery.min.js?vmver=9194
    – Antonio
    Aug 23 '16 at 14:43
  • Try wrapping the code you provided inside jQuery(document).ready(function(){ ... });
    – Lodder
    Aug 23 '16 at 14:47
  • u can disable dropdowns/regions libs (js of course) in virtuemart cfg (templates tab) and now no error
    – boniq
    Jul 4 '18 at 20:39

First check if you have two jQuery versions by pressing CTRL + U (it shows the source code on Chrome), normally jQuery chosen is not a function because JQuery.fn doesn't know who is chosen function, that means sometimes jQuery conflict. In VM3 have a option to enable the jQuery library in website, uncheck this option in shop, search by others components or modules that you've installed recently, only keep jui/js/jquery... (min.js, no-conflict, migrate), if you tried so much and can't remove you can force the disable with unset() function at index.php of your template from the others jQuery of others extensions/plugins etc.


<?php unset($this->_scripts['/media/system/js/mootools-core.js']); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.