I am building a web app using Ruby on Rails. I would like to add some Javascript to a CoffeeScript file
var month = <%= @pin.duedate.month %>;
var day = <%= @pin.duedate.day %>;
var date = new Date(year, month, day);
$("#due_date_timer").countdown({until: date});
At the moment my CoffeeScript file (pins.js.coffee) includes this:
$ ->
$('#pins').imagesLoaded ->
$('#pins').masonry
itemSelector: '.box'
isFitWidth: true
What is the proper way to include the Javascript into a CoffeeScript file?
Update
Followed Amadan's direction
In pins.js.coffee
$ ->
$('#pins').imagesLoaded ->
$('#pins').masonry
itemSelector: '.box'
isFitWidth: true
year = <%= @pin.duedate.year %>
month = <%= @pin.duedate.month %>
day = <%= @pin.duedate.day %>
date = new Date(year, month, day)
$("#due_date_timer").countdown({until: date})
I get an error
ExecJS::ProgramError
unexpected =
year = <%= @pin.duedate.year %>