I have:
-
controller/reports_controller.rb -
views/reports/index.html.erb -
assets/reports.js
I have an image in index.html.erb:
<div class="main_mark">
<img src="/assets/welcome_main.png" alt="main" class="main_mark_image" />
</div>
I want to print an message to the screen (alert message) when the user presses the image. so I want to write a function in reports.js that print the message.
reports.js:
$(document).ready(function() {
$(".main_mark_image").click(function () {
alert("alon");
});
});
but I think I have to relate between the java script the the html.
any help appreciated!
When using an external script you need to tell your HTML file:
The above assumes that your ‘assets’ folder is in the same folder as your index. You also need to include the jQuery library. It’s available for download or you can use Google’s:
Or, for jQuery UI:
Hope this helps.