I'm trying to get a function into the asset pipeline in coffeescript
If I use pure javascript,
mymodel.js
function restrictPlayback(event) {
// Trying to stop the player if it goes above 1 second
if (event.currentTime > 10) {
event.pause();
event.currentTime = 0
}
}
This compiles fine and the function works.
If I put the following:
mymodel.js.coffee
restrictPlayback = (event) ->
# Trying to stop the player if it goes above 10 seconds
if event.currentTime > 10
event.pause()
event.currentTime = 0
I get the following error
Uncaught ReferenceError: restrictPlayback is not defined
What am I doing wrong?
restrictPlayback.restrictPlayback? If it's before you declare it, that's likely what the issue is