I need to use a JavaScript library in my CoffeeScript application. Since I am not familiar with both languages I try something simple. My coffeescript file:
empty = require('models/empty')
class Contact extends Spine.Model
@configure 'Contact', 'name', 'email'
@extend Spine.Model.Local
create: ->
empty.one()
super
module.exports = Contact
And my Javascript file named empty.js :
console.log('what')
function one () {
console.log('one')
};
The coffeescript file works normally, although I cant get empty.one() to work. 'what' is printed on console which means that the JS file is loaded. Although I get the following error when one() is called:
Uncaught TypeError: Object # has no method 'one'
I have tried many different ways of defining the function, as variable, and using different syntaxes I found on tutorial, although none of this seems to work. Can someone point the mistake I am making?