javascriptjqueryjquery-widgets

JQueryUi Autocomplete Combobox sometimes not loading properly in Firefox


I am using JQueryUi 1.12.1 version and JQuery 3.2.1 version.

I am trying to use 2 JQueryUI Autocomplete Comboboxes in my website, so I copied Combobox code from here, changed it a little bit and added to JS file twice (with widget names 'combobox' and 'combobox2', they have diffrent logic and they are dependent on each other). In latest version of Chrome it's working as intended, but in Firefox sometimes (mostly on first loading of page after closing browser, but if I refresh page constantly something like 1 of 10 tries is ending up with error) I have an error saying: TypeError: jQuery(...).combobox is not a function.

Here is my js file code:

jQuery(document).ready(
    function ($) {
    $.widget( "custom.combobox", {
    //code...
    });

    $.widget( "custom.combobox2", {
    //code...
    });

    jQuery('#id_substancename').combobox();
    jQuery('#id_casnumber').combobox2();
    //code...
});

Solution

  • Changing:

        jQuery('#id_substancename').combobox();
        jQuery('#id_casnumber').combobox2();
    

    To:

        $('#id_substancename').combobox();
        $('#id_casnumber').combobox2();
    

    Fixed the problem.