Rails 6: How to add jquery-ui through webpacker?

后端 未结 8 907
失恋的感觉
失恋的感觉 2021-01-05 04:12

I\'m currently trying to implement a datepicker into my application, the problem is that there is no documentation on how to add the jquery-ui-rails gem through

8条回答
  •  抹茶落季
    2021-01-05 04:47

    Kalman's answer puts jQuery within the scope of the scripts in the app/javascript directory but not with any in-line javascript that you may have on your webpages.

    If you want to access jQuery from the scope of the webpage, you could can put jQuery under the public directory then modify app/views/layouts/application.html.erb to link to it like this:

    
    
      
        JqueryTest
        <%= csrf_meta_tags %>
        <%= csp_meta_tag %>
    
        <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    
    
        <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
        
        <%= stylesheet_link_tag "/jquery-ui-1.12.1.custom/jquery-ui.min.css" %>
        
    
    
      
    
      
        <%= yield %>
      
    
    
    

提交回复
热议问题