Topic: Unusual RJS error

Hi,
I am getting the following error in my RoR application:
RJS error:

TypeError: element is null

Element.update("notice", "Comment Posted");
Element.update("allcomments", "<table>\n\n\n  <tr>\n\n    <td>waht now?\n</td>\n  </tr>\n\n    </tr>\n\n  <tr>\n\n    <td>asdfasdfa</td>\n  </tr>\n\n  <tr>\n\n    <td>asdfasdf</td>\n  </tr>\n\n</table>\n\n<br />\n");

But when I hit the refresh button, I can see my partial updated.

Here's my code:

show_comments View:

    <table>
    <% comments.each do |my_comment| %>
      <tr>
    
        <td><%=h my_comment.comment%></td>
      </tr>
    <% end %>
    </table>

show View:

    <div class="wrapper">
        <div class="rescale">
          <div class="img-main">
            <%= image_tag @deal.photo.url %>
          </div>
    
        </div>
        <div class="description">
        <p class ="description_content">
          <%=h @deal.description %>
        </p>
        </div>
        </div>
        <p>
          <b>Category:</b>
          <%=h @deal.category %>
        </p>
    
        <p>
          <b>Base price:</b>
          <%=h @deal.base_price %>
        </p>
    
        <%#*<p>%>
          <%#*<b>Discount:</b>%>
          <%#=h @deal.discount %>
        <%#*</p>%>
    
        <%= link_to 'Edit', edit_deal_path(@deal) %> |
        <%= link_to 'Back', deals_path %>
    
        <p>
          <%= render :partial=>'deal_comments', :locals=>{
              :comments=>Comment.new(:deal_id=>@deal.id)} %>
        </p>
        <div id="allcomments">
          <%=  render :partial=>'show_comments', :locals=>{
            :comments=>Comment.find(@deal.comments)} %>
        </div>

Controller:

        def create
            @comment = Comment.new(params[:comment])
            render :update do |page|
              if @comment.save
                page.replace_html 'notice', 'Comment Posted'
              else
                page.replace_html 'notice', 'Something went wrong'
              end
              page.replace_html 'allcomments', :partial=> 'deals/show_comments',
                :locals=>{:comments=> @comment.deal.comments}
            end
      end

      def show_comments
        @deal = Deal.find(params[:deal_id])
        render :partial=> "deals/show_comments", :locals=>{:comments=>@deal.comments}
      end
    end

Re: Unusual RJS error

I don't see the "notice" ID used in your view ... I see allcomments though.
Looks like you are assuming the "notice", probably from a flash notice is in the DOM?

Re: Unusual RJS error

Thanks pullmonkey, I had misspelled notice in my layout view.