I'm trying to pass database value retrieved by ruby to javascript,to handle some div display.
Strange thing is,when I pass number(means I retrieve number from database and pass to js),it works fine,as follow,this load_web is a short int.
if (<%= @device.load_web %>==0)
{ $('.somediv').find('input,textarea,select').attr('disabled',true); }
});
But when I try same method,passing string to js,it returns me HTMLDIVElement,which is very strange.
if(<%= @device.brand%>=="apple")
{
alert("apple");
}
else
{
alert(<%= @device.brand %>);
}
The data in my database for this colum is "apple",but the logic falls into else loop,and give me a "object HTMLDIVElement" message.
Why is so?
EDIT:
I try use alert(<%= @device.brand %>.innerHTML);
and get the following message:
