简体   繁体   中英

How do I add jQuery plugins on my rails app

I will use the GMAP3 Plugin for JQuery in my rails app.

I already put the javascript file in app/assets/javascripts/gmap3/gmap3.min.js .

I will use this jQuery plugin only on the welcome page. What files do I need to modify (and how) in order to make use the plugin?

You should put the file ( for a Rails 3 project ) in vendor/assets/javascripts/gmap3.min.js and then you should add it in two ways:

<%= javascript_include_tag 'gmap3.min' %>

or in some added file like

//In (for example) application.js

//= require gmap3.min

If you added the file correctly, that is, in a page that you are seeing (you can check this in your browser console, usually in Resources or Network ), you can use it.

Some links for you to see:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM