I'm starting to feel crazy because what I want to do is so simple: write a line of javascript in my Rails application.js file that will cause a script somewhere else in the app to execute. I've tried it with jQuery.get() and jQuery.getScript() but nothing seems to work.
Here's some sample code from my application.js file:
#application.js
$(document).ready(function() {
$(".button").click.function(){
$.get($(this).attr("href"), null, null, "script");
});
});
or
#application.js, excerpt
$.getScript("index.js.erb", function(){
alert('script has run');
});
among other variations. I've tried putting the index.js.erb file in the same views folder as my current page, or in the javascripts folder, and even tried making it a pure .js file. The script itself can't be the problem, I'm trying it with lines as simple as:
#app/views/index.js.erb)
$('.header').text('new text')
Nothing's working for me, please help!