RJS error: TypeError: element is null

Hi All,

I got RJS error: TypeError: element is null while using ajax.

I used in view

<%= periodically_call_remote(:url=>{:action=>'get_user_list', :id=>'1'}, :frequency => '5') %>

in controller

      render :update do |page|         page.replace_html 'chat_area', :partial => 'chat_area', :object => [@chats, @user] if @js_update       end

in partial chat_area

<% if !@chats.blank? && !show_div(@chats).blank?%>     <% show_div_id=show_div(@chats) %>   <% for chat in @chats %>       <div class="popup" id="chat_area_<%= chat.id %>" style="display:<%= (chat.id == show_div_id)? 'block' : 'none' %>;">

        <% form_remote_for(:chat, :url => {:controller=>'chats', :action=>'create', :id=>1}, :html=>{:name => "form_#{chat.id}"}, :complete=>"resetContent('#{chat.id}');") do |f| %>         <div style="display:none;">             <%= f.hidden_field :sessionNo, :value=>chat.sessionNo %>             <%= f.text_area :chatContent, :id=> "chatContent_field_#{chat.id}", :cols=>"100", :rows=>"6", :onKeyPress=>"return submitenter(this,event);" %>           </div>             <input type="image" src="images/chat/send-hover.png" value="Send" onclick="return submit_button('<%= chat.id %>')"/>         <% end %>       </div>

    </div>   <% end %>

<% else %>       <div class="popup" id="chat_area_none" style="display:'block';">           <input type="image" disabled ="disabled" src="images/chat/send.png" style="cursor:default;" value="Send" />       </div> <% end %>

Any help is appreciated.

Regards,

Salil Gaikwad

Hi All,

I got RJS error: TypeError: element is null while using ajax.

I used in view

<%= periodically_call_remote(:url=>{:action=>'get_user_list', :id=>'1'}, :frequency => '5') %>

in controller

 render :update do |page|
   page\.replace\_html  &#39;chat\_area&#39;, :partial =&gt; &#39;chat\_area&#39;, :object

=> [@chats, @user] if @js_update end

I believe this is expecting to find a div with id chat_area to replace. I do not see this div in the code below, though I may be just not be seeing it.

Colin

I believe this is expecting to find a div with id chat_area to replace. I do not see this div in the code below, though I may be just not be seeing it.

Colin

Following div is present on my index.rhtml

<div id="chat_area">   <%= render :partial=>'chat_area' %> </div>

I don't know what is the problem with this div or partial's content while using same technique i am updating my other div's

Regards,

Salil Gaikwad

Hi All,

I find it out why it happens because I didn't close div above the "chat_area" properly. the only thing i did isclose the div and it works like a magic, neways thanks to all

Reagrds,

Salil Gaikwad

Hi All,

I find it out why it happens because I didn't close div above the "chat_area" properly. the only thing i did isclose the div and it works like a magic, neways thanks to all

I suggest installing the html validator add-in to Firefox and that will check the html of your pages as you develop them. This would have shown your missing /div immediately.

Alternatively you can paste the html of the page into the w3c html validator for checking but this is much less convenient.

Colin