0

I have a view with the following namespace

view/kids/registration/new.html.haml

Now I need to create a js file to this view, so I created a file in the following path:

assets/javascripts/kids/registration/new.js

Then I add the following lines to the application.js:

//= require ./kids/registrations/new

But it does not work. What I'm doing wrong. I'm checking the DOM (localhost:3000/kids/sign_up) but I never find line with this javascript file.

Thanks in advance for your help.


Adding the route

new_kid_registration GET /kids/sign_up(.:format) frontend/registrations#new

What I'm doing wrong.

Thanks.

2

2 Answers 2

1

Try //= require kids/registrations/new or //= require kids/registrations/new.js

Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't work Bob. I don't know what's the problem.
0

I had faced similar problems while adding stylesheets to assets (Link to my question)

Here are few things you might wanna try:

  • As suggested by BOB add the require statements to application.js

  • I remember adding the list of files to application.rb as:

       config.assets.precompile += ['jquery.colorbox.js','colorbox.css', 'reportng.css', 'reportng.js'] 
    
  • Your JS file can be placed anywhere in lib/assets/javascripts, assets//assets/javascripts & vendor/assets/javascripts
  • Try using the <%= javascript_include_tag "your_js_file_name" %> in your view file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.