Jump to content

The ultimate community for Ruby on Rails developers.


functions dependencies in JS


  • Please log in to reply
1 reply to this topic

#1 lucedan



  • Members
  • 9 posts

Posted 31 August 2014 - 05:25 PM

I apologizes if the topic is wrong.


I really love Ruby on Rails, though I've started lately, because it forces me to be clean coding.

But I'd like to be cleaner creating JS functions on different files, to be called when needed.

This the model:



function_1.js -> function_1()

function_2.js -> function_2()

function_3.js -> function_1.run(), function_2.run()


how to do that?

I have already tried in creating new files but them seem not to communicate to each other.




#2 Ohm



  • Moderators
  • 529 posts
  • LocationCopenhagen

Posted 01 September 2014 - 07:47 AM

Make sure that you require the scripts in application.js either with 

//= require 'function_1'
//= require 'function_2'
//= require 'function_3'

or by requiring the folder

//= require_tree ./application

Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk

Also tagged with one or more of these keywords: javascript

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users