Monday, May 20, 2024
135
rated 0 times [  138] [ 3]  / answers: 1 / hits: 16797  / 9 Years ago, sun, december 6, 2015, 12:00:00

I'm a newbie ruby on rails developer. I've just created my first application and made use of the the bootstrap carousel. Now, I want to add some javascript. My application does not have any custom javascript at this point. What I want to do is when the left or right button on the carousel is pressed, I want an alert to pop up. Preferably, I want to include my javascript file in the /assets/javascript directory. The purpose of this is to just learn how to add new javascript files in my application.


More From » ruby-on-rails

 Answers
65

Adding your custom javascript to your rails app is real easy, just follow the steps below :-




  • create a file (say custom.js) under app/assets/javascripts/

  • Open up your manifest file i.e application.js (this is the file where you need to include every javascript file you want to load into your rails app, add the script name to it //=require custom.

  • Visit your rails app from browser and check the page source and search for custom.js being loaded or not thats all.


[#64152] Thursday, December 3, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lucianod

Total Points: 667
Total Questions: 106
Total Answers: 92

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
lucianod questions
;