8.4.2 TypeError: $(...).select2 is not a function

Permalink
view:
<select multiple="multiple" name="mySelect" class="mySelect">
<option value="Slower">Slower</option>
<option value="Slow">Slow</option>
<option value="Medium">Medium</option>
<option value="Fast">Fast</option>
<option value="Faster">Faster</option>
</select>
<script>
    $(document).ready(function(){
        $('.mySelect').select2();
    });
</script>

controller:
public function on_start() {
        $this->set('app', $this->app);        
        $this->requireAsset('css', 'select2');
        $this->requireAsset('javascript', 'select2');
    }

And I have an error "TypeError: $(...).select2 is not a function" and the select input doesn't display like select2. What could be wrong?

Thank you.

linuxoid
 
midhunsaffron replied on at Permalink Reply
midhunsaffron
Please try this code to load the select2 assets
$this->requireAsset("select2");
.