Getting select2 to work with active admin

后端 未结 2 643
说谎
说谎 2021-01-05 17:52

I am working with an app with Active Admin and needed to select multiple values from a select input, I have added the Select2 gem which adds all the relevant the JS and CSS

相关标签:
2条回答
  • 2021-01-05 18:34

    Problem solved, use chosen js instead of select2, works equally as well as select2 but without the issues in active admin.

    https://github.com/gregbell/active_admin/issues/2267#issuecomment-19197807

    0 讨论(0)
  • 2021-01-05 18:48

    This is caused by Active Admin's decision to wrap its CSS styles inside .active_admin selector. As a result, most of third-party gem's CSS styles become less specific, and their appearance become broken.

    For select2, and all gems whose CSS files are inside "stylesheets" folder, add the following lines at the bottom of active_admin.css.scss:

    body.active_admin {
      @import "select2";
    }
    

    This will give all of select2's styles body.active_admin selector, making them more specific than Active Admin's styles.

    0 讨论(0)
提交回复
热议问题