Rjs error TypeError: element.getElementsByTagName is not a function in rails 3+jquery

hi,

i am using rails 3.0.10

i am trying with sample application for searching data from table and
updating
my search.html.erb file is
<%= form_for (@employee) do |s|%

<%= s.text_field :name%> <%= s.text_field :emp_id, :onfocus => 'sal(document.getElementById('employee_name').value);'%>
<% end %>

when i click tab it calls sal() jquery function and i sent the data to
action, in action parameter is
processed well, but while replacing div with partial page i am getting
following error like

RJS error:

TypeError: element.getElementsByTagName is not a function

Element.update(“upc_search”, "\n \n

\n <table border =
"1">\n \n \n No
\n
\n <input tyep="text" value="1"
size="30"/>\n \n \n <label for=
"id" >id\n
\n <input tyep="text
" value="0123456789123" size="30" />\n \n

\n Name\n
\n \n \n \n \n
\n\n
\n \n");

i used
https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js,
https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.js
for jquery process

could any one provide me solution ?

thanks,
-pab

You probably should’t call prototype methods when you’ve chosen jquery
as your js framework.

On Wed, Sep 14, 2011 at 4:58 AM, Pab [email protected] wrote:

RJS error:

TypeError: element.getElementsByTagName is not a function

Exactly what it says: getElementsByTagName is a basic JavaScript
function of document. So you need to look at your JS to see where
that’s getting muddled…


Hassan S. ------------------------ [email protected]

twitter: @hassan

Hassan S. wrote in post #1021992:

On Wed, Sep 14, 2011 at 4:58 AM, Pab [email protected] wrote:

RJS error:

TypeError: element.getElementsByTagName is not a function

Exactly what it says: getElementsByTagName is a basic JavaScript
function of document. So you need to look at your JS to see where
that’s getting muddled…

wrong – it can be called on any html element.

Hi,

how to avoid using prototype method ?

thanks,
-pab

On Wed, Sep 14, 2011 at 1:55 PM, 7stud – [email protected] wrote:

TypeError: element.getElementsByTagName is not a function

Exactly what it says: getElementsByTagName is a basic JavaScript
function of document. So you need to look at your JS to see where
that’s getting muddled…

wrong

Perhaps you could be a little more explicit about what part of that you
consider to be “wrong” ? :slight_smile:


Hassan S. ------------------------ [email protected]

twitter: @hassan