Jamal Abdul Nasir
Jamal Abdul Nasir

Reputation: 2667

RJS in controller

TypeError: Element.update is not a function

   respond_to do |format|
    format.js do
      responds_to_parent do
        render :update do |page|
          page.replace_html 'errorLay', :text => "Page with the same name already exists."
          page.show 'errorLay'
          page.delay(2) do
            page.hide 'errorLay'
          end
        end
      end
    end
  end

Upvotes: 0

Views: 658

Answers (3)

dombesz
dombesz

Reputation: 7899

Probably it's wrong because you try to use responds_to_parent within a respond_to block.

I don't know if you can mix them. I suggest to try without the respond_to block. To respond properly to request types you can do like

if request.xhr?
  responds_to_parent do
    render :update do |page|
      page.replace_html 'errorLay', :text => "Page with the same name already exists."
      page.show 'errorLay'
      page.delay(2) do
        page.hide 'errorLay'
      end
    end
  end
end

In this way only responds with js, when was an ajax call. But i suggest to use rjs file instead rendering from controller.

Upvotes: 1

Salil
Salil

Reputation: 47482

in your controller only write

   render :update do |page|
      page.replace_html 'errorLay', :text => "Page with the same name already exists."
      page.show 'errorLay'
      page.delay(2) do
        page.hide 'errorLay'
      end
    end

and whaterver you are using for Ajax link_to_remote or anything else don't write :update=>'some_div'

Upvotes: 1

Pär Wieslander
Pär Wieslander

Reputation: 28934

It sounds like you've forgotten to include prototype.js in your layout. Make sure you have

<%= javascript_include_tag "prototype" %>

in the HEAD section of your document layout.

Upvotes: 0

Related Questions