I have a "coordinate.js" javascript in public/javascripts and in app/views/dicoms, I have a "show.html.erb".
For example, if I want to call the getWidth function from the .js file in the view what should I do? I remember it working for me as I get a message box giving me the alert but don't know what went wrong. For example, I have this functionin the .js file function getWidth() { var image = document.getElementById("dicom_image"); imageWidth = image.width; return imageWidth; alert("Image Width is " + image.width); } And, here is my "show.html.erb" file: <%= javascript_include_tag "coordinate" %> <canvas id="draw" > </canvas> <p id="notice"><%= notice %></p> <p> <b> Name </b> <%= @dicom.name %> </p> <p> <b> Image </b> </p> <div id="image_element" style="display: none;"> <p> <%= image_tag @dicom.photo.url , :id => 'dicom_image' %> </p> </div> <%= update_page_tag do |page| page << "getWidth();" end %> <%= update_page_tag do |page| page << "drawImg();" end %> <%= update_page_tag do |page| page << "drawLine();" end %> <%= link_to 'Edit', edit_dicom_path(@dicom) %> <%= link_to 'Back', dicoms_path %> Please let me know what you think. Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.