如何在我的rails应用程序上添加jQuery插件

时间:2022-10-31 23:01:09

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

我将在我的rails应用程序中使用JAP的GMAP3插件。

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

我已经将javascript文件放在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?

我将仅在欢迎页面上使用此jQuery插件。为了使用插件,我需要修改哪些文件(以及如何)?

1 个解决方案

#1


4  

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:

您应该将文件(对于Rails 3项目)放在vendor / assets / javascripts / gmap3.min.js中,然后您应该以两种方式添加它:

<%= 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:

一些链接供您查看:

#1


4  

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:

您应该将文件(对于Rails 3项目)放在vendor / assets / javascripts / gmap3.min.js中,然后您应该以两种方式添加它:

<%= 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:

一些链接供您查看: