0

I want to acess a variable that is defined in an asset file. Currently, my code looks like this:

<script type="text/javascript"> handler = something; </script>

Then I can use "handler" with no problems inside the html. The case is that I want to move this piece of JS to a file inside assets folder, to a cleaner view, assuming that the file is already being loaded by asset pipeline.

Any idea?

1 Answer 1

2

Use window.handler = something to set global variable.

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

1 Comment

Clear and awesome. Thanks mate.

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.