[英]ruby on rails - add javascript
I'm a newbie ruby on rails developer.我是 Rails 开发人员的新手 ruby。 I've just created my first application and made use of the the
bootstrap
carousel.我刚刚创建了我的第一个应用程序并使用了
bootstrap
carousel。 Now, I want to add some javascript
.现在,我想添加一些
javascript
。 My application does not have any custom javascript
at this point.我的应用程序此时没有任何自定义
javascript
。 What I want to do is when the left
or right
button on the carousel is pressed, I want an alert
to pop up.我想要做的是当按下旋转木马上的
left
或right
按钮时,我想要弹出alert
。 Preferably, I want to include my javascript
file in the /assets/javascript
directory.最好,我想将我的
javascript
文件包含在/assets/javascript
目录中。 The purpose of this is to just learn how to add new javascript
files in my application.这样做的目的是学习如何在我的应用程序中添加新的
javascript
文件。
Adding your custom javascript to your rails app is real easy, just follow the steps below :-将您的自定义 javascript 添加到您的 rails 应用程序非常简单,只需按照以下步骤操作:-
For Rails 6对于 Rails 6
Add your javascript code under /app/javascript//file.js在 /app/javascript//file.js 下添加您的 javascript 代码
and then in app/packs/application.js然后在 app/packs/application.js
require("<folder name>/file")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.