Just started exploring Meteor, and right off the bat I've got something that's throwing me for a loop:
1) I installed it and ran meteor add coffeescript
.
2) I converted the myapp.js file to .coffee.
3) I saved the file.
At this point, Meteor generates a new myapp.js file by compiling the coffeescript file. Ok, that seems logical.
4) I ran meteor
. I see the app at localhost:3000
, however if I hit the button the button click event is firing twice: once from myapp.js
and once from myapp.coffee
.
Just to see a test I added this:
Template.hello.events "click input": ->
# template data, if any, is available in 'this'
console.log "You pressed the button" if typeof console isnt "undefined"
$('body').append('<div>test</div>')
When I click the button two divs get added.
Now, if I delete the compiled myapp.js
file, the "you pressed the button" only fires once, and only one div is appended to the page. However if I save the .coffee file a new .js file is generated each time, and now all the JS executes twice.
How are you supposed to use CoffeeScript with Meteor so your code only executes once?