A
A
Anton Misyagin2016-03-25 00:09:04
Ruby on Rails
Anton Misyagin, 2016-03-25 00:09:04

Global functions in CoffeeScript?

I am finally switching to CoffeeScript in my rails project. Before that, everything was written in pure JavaScript. A problem arose immediately.
File1

$ ->
    function1 -> some code

Previously I had:
$(function(){
  function1 = function(){some code}
});

File2
$ ->
  function1()

Previously it was:
$(function(){
  function1();
});

Everything works in pure Javascript. And then it wraps in an additional scope or how to call it correctly and gives an error function1 is not defined
How to get around this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question