Forum: Ruby on Rails RJS sporadic error message

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C4bfcc81ac9281cb905f38e97e4d4e0b?d=identicon&s=25 Shandy Nantz (snantz)
on 2009-04-20 19:26
I have this form that allows a user to enter a username and save it,
assocciating your profile with theirs via an id. A list gets updated and
a partial is displayed. The problem is that when I hit the submit button
to this form to make this all happened I (sometimes, but more often then
not) get an RJS error that reads:
  TypeError: Cannot set property 'innerHTML' of bull.
I hot OK and another error pops up giving me this long string of what
appears to be JavaScript or Ajax code?

Main View Code:
<div id = "update_first" align = "center">
  <span class="header">Travel Arranger Pages</span><br /><br />
  <b class = "table-header">The profiles for which you are responsible
        </b><br />
  <hr width = "67%">
  <div id = "travel-managers-users">
    <%= render :partial => 'show_my_users' %>
  </div>
  <hr width = "67%">
  <br />
  <div id = "company_users">
    <%= render :partial => 'add_new_profile' %>
  </div>
</div>

Partial - add_new_profile:
<% form_remote_tag :url => {:action => 'add_profile_auto', :id =>
@user.id },
  :complete => "new Effect.Appear('airport'); new
Effect.Pulsate('airport');"
  do -%>
  <b>Type in username to add to your list: </b><br />
  <%= text_field_with_auto_complete :user, :username,
     {:value => '', :size => 45},
     {:url => { :action => "auto_complete_for_user_username",
        :id => @user.primary_account_id },
      :skip_style => true} %>
  <%= submit_tag 'Add Name'%>
<% end -%>
....

Controller code - add_profile_auto:
.....
   render :update do |page|
     page.replace_html 'travel-managers-users', :partial =>
'show_my_users'
     page.replace_html 'company_users', :partial => 'add_new_profile'
   end
.....

Any ideas of why I am getting this error. I am just lost. Like I said I
sometimes get the error and sometimes I don't.

Thanks in advance,

-S
91a72b0ad3e43e3ef3a31816667ec694?d=identicon&s=25 bill walton (Guest)
on 2009-04-24 16:47
(Received via mailing list)
Hi Shandy,

On Mon, 2009-04-20 at 19:26 +0200, Shandy Nantz wrote:
> I have this form that allows a user to enter a username and save it,
> assocciating your profile with theirs via an id. A list gets updated and
> a partial is displayed. The problem is that when I hit the submit button
> to this form to make this all happened I (sometimes, but more often then
> not) get an RJS error that reads:
>   TypeError: Cannot set property 'innerHTML' of bull.
> I hot OK and another error pops up giving me this long string of what
> appears to be JavaScript or Ajax code?

I've never seen this myself but can offer some general info / advice.

In reverse order, yes.  What you're seeing in the error dialog is the
javascript that was being attempted when the error was encountered.

The fact that you're getting a 'TypeError', and the error itself is
telling you that bull doesn't have the property you're trying to set.
It looks like you're using replace_html on something that has no html
'insides'.  For example...

assuming:
<div id="bull_ring">
  <img id="bull" src="bull.png />
</div>

this will work:
page.replace_html "bull_ring", "new_image.png"

this will not:
page.replace_html "bull", "new_image.png"

I'd start by taking a look at the HTML in Firebug prior to hitting the
submit and compare what's there with what you need wrt your RJS.

HTH,
Bill
This topic is locked and can not be replied to.