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

286 views
Skip to first unread message

Pab

unread,
Sep 14, 2011, 7:58:34 AM9/14/11
to Ruby on Rails: Talk
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|%

<div id ="search_details">
<%= s.text_field :name%>
<%= s.text_field :emp_id, :onfocus =>
'sal(document.getElementById('employee_name').value);'%>
</div>
<% 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 <div >\n <table border =
\"1\">\n <tr>\n <th>\n <label >No</label>
\n <br />\n <input tyep=\"text\" value=\"1\"
size=\"30\"/>\n </th>\n <th>\n <label for=
\"id\" >id</label>\n <br />\n <input tyep=\"text
\" value=\"0123456789123\" size=\"30\" />\n </th>\n
<th>\n <label for=\"Name\" >Name</label>\n <br />
\n <input tyep=\"text\" value=\"Lotion\" size=\"30\" />\n </
th>\n </tr>\n </table>\n </div>\n\n <br />\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


7stud --

unread,
Sep 14, 2011, 1:39:11 PM9/14/11
to rubyonra...@googlegroups.com
You probably should't use prototype methods when you've chosen jquery as
your js framework.

--
Posted via http://www.ruby-forum.com/.

Hassan Schroeder

unread,
Sep 14, 2011, 1:59:37 PM9/14/11
to rubyonra...@googlegroups.com
On Wed, Sep 14, 2011 at 4:58 AM, Pab <prabu...@gmail.com> 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 Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

7stud --

unread,
Sep 14, 2011, 4:55:05 PM9/14/11
to rubyonra...@googlegroups.com
Hassan Schroeder wrote in post #1021992:

> On Wed, Sep 14, 2011 at 4:58 AM, Pab <prabu...@gmail.com> 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*

Hassan Schroeder

unread,
Sep 14, 2011, 5:04:42 PM9/14/11
to rubyonra...@googlegroups.com
On Wed, Sep 14, 2011 at 1:55 PM, 7stud -- <li...@ruby-forum.com> 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" ? :-)

Pab

unread,
Sep 15, 2011, 10:54:32 AM9/15/11
to Ruby on Rails: Talk
Hi,

how to avoid using prototype method ?

thanks,
-pab
Reply all
Reply to author
Forward
0 new messages