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);
}
If you are learning and want to learn how to do everything nice and efficiently learn how to use a javascript library, if you are in a hurry
and dont have time to learn keep doing it the way you have. The code i gave you is for when you are not using any library.
If you are learning and want to learn how to do everything nice and
efficiently learn how to use a javascript library, if you are in a hurry
and dont have time to learn keep doing it the way you have. The code i
gave
you is for when you are not using any library.
looks like you are not using any javascript library but are calling a
prototype method or something
var img = document.getElementById("dicom_image");
getElementById is core JavaScript, not a Prototype extension. If you're
going to spread misinformation like this, please do us all a favor and
stop posting.
var width = img.clientWidth;
var height = img.clientHeight;
he was talking to me, when you set you called getHeight() and getWidth() you used then same names prototype uses, but i didnt notice
you had made your own methods with those name, so he thought that when i said
radhames brito wrote:
looks like you are not using any javascript library but are calling a
prototype method or something
i was refering to this
var img = document.getElementById(“dicom_image”);
but i was reffering to this
<%= update_page_tag do |page|
page << “getWidth();”
end
%>
i user this
var img = document.getElementById(“dicom_image”);
to point out that you are not using any libraries but you seem to be calling getHeight() and getWidth() that are prototype methods
If you check my question, you will see the following:
function getWidth() {
var image = document.getElementById("dicom_image");
imageWidth = image.width;
return imageWidth;
alert("Image Width is " + image.width);
}
Which I then tried to call in "show.html.erb" using:
<%= update_page_tag do |page|
page << "getWidth();"
end
%>
OK, then I failed to read properly (helped along by Radhames' lack of
proper quoting) and I'm sorry about that. Apparently I completely
misunderstood what Radhames was getting at. I'll try to read more
carefully in future. Radhames, please try to quote more relevant
material.
@marnen i comment via gmail, so i forget about the quoting, also , note that im not a native english speaker and some times my ideas dont come across the way
i wanted them to. : /