I am trying to run a simple javascript file based on the #381 railscast episode. When I place an alert in my javascript file, though, it does not appear when I load my page. I am sure that the file itself is loaded as I checked in the view source. Any ideas why it isn’t loading?
application.js:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require js-routes
//= require twitter/bootstrap
//= requre_self
//= require_tree .
images.js.coffee:
jQuery ->
alert("hello world")
$('#new_image').fileupload
dataType: "script"
Try removing the files causing JS errors from application.js. You could also try removing
require_tree .which recursively includes all files in app/assets/javascripts, but you’ll have to manually add all files that need to be included if you do this.