Does my ruby on rails app have to use coffeeScript or could I can I Just use plain javaScript?
-
6remove .coffee from the end of your file and it runs plain js. so application.js.coffee -> application.jsSam– Sam2013年12月19日 16:03:13 +00:00Commented Dec 19, 2013 at 16:03
4 Answers 4
You need to ensure not having the same filename both in javascript and coffeescript.
For example: having both the files
assets/javascripts/application.coffee
assets/javascripts/application.js
will only get the coffeescript loaded.
Comments
Yes, you can just use Javascript. You have your files in app/assets/javascripts/*.js . On local dev, do a view source and you will see your files there.
On production, the Asset Pipeline will concatenate and minify.
Comments
You can also write plain JS in CoffeeScript files, just put ` around it:
hi = `function() {
return [document.title, "Hello JavaScript"].join(": ");
}`
1 Comment
you can write whatever you want jquery or javascript just make sure the extension for that is js
Comments
Explore related questions
See similar questions with these tags.