select2-rails gem is not working on Rails4

前端 未结 4 561
一个人的身影
一个人的身影 2021-01-02 17:55

I have tried given documentation for the select2-rails gem, but my browser console still throws an error.

Uncaught TypeError: $(...).select2 is not a

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 18:32

    On rails 5 using CoffeeScript and turbolinks I had to use the line:
    $(document).on "turbolinks:load", -> before everything so that the code gets executed when the desired page with the select tag is loaded.

提交回复
热议问题