lou / multi-select

A user-friendlier drop-in replacement for the standard select with multiple attribute activated.
loudev.com
MIT License
1.9k stars 439 forks source link

multiSelect not found when put into ajax function #332

Closed connorpwilliams closed 4 years ago

connorpwilliams commented 4 years ago

I have a javscript file containing some custom logic that gets loaded into the header of an HTML page via a Drupal 8 module. The multi-select js file is first, the quicksearch file next and a little ways down is my custom js file.

When the js file has

$(#myselector select).multiSelect(.....)

The function loads just fine, but when I have something like

$.ajax({
    url: '...',
    success: function(){
        $(#myselector select).multiSelect(.....)
    }
}

I get Uncaught TypeError: $(...).multiSelect is not a function

Any idea why putting the multiSelect() function into the callback of ajax would be causing issues?

I'm using jQuery 3.4.1 for reference

connorpwilliams commented 4 years ago

jQuery scope issue, closing as it's a non-issue