0

I have two files: first one is a plain jQuery, and a second one is a Coffeescript

jQuery file:

$(document).ready(function(){
    checkPrice();
});

CoffeeScript file:

$ ->
   checkPrice = ->
     alert("OK");

I get following error: "Unhandled Error: Undefined variable: checkPrice"

In the template they are included in opposite direction: coffeescript file, then jquery file.

Is there some way to make them working together ?

1 Answer 1

1

OK. Got it.

checkPrice should have been declared as global, so in coffeescript file I have:

window.checkPrice =->
  alert("OK");

And now it works!

Thank's everyone who was there to help me anyway.

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

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.