RJS in action vs .js file (page object)

Hi,

Would anyone be able to suggest why the following works in the action
but not when placed in a .js file, called by the action?

It’s the page << “$(‘basket_popup’).popup.show();” line I’m interested
in.

def show

respond_to do |format|
  format.js do
    render :showbasket do |page|
      page << "$('basket_popup').popup.show();"
    end
  end
end

end

However when I have show.js and remove the block from format.js it
fails. I get a javascript error on the page along the lines of popup
has no properties/attributes?

-show.js-

page << “$(‘basket_popup’).popup.show();”

I’m sure it’s a simple one but I can’t see it??

On 16 Jun 2008, at 11:57, Andrew E. wrote:

-show.js-

page << “$(‘basket_popup’).popup.show();”

I’m sure it’s a simple one but I can’t see it??

Name your file show.js.rjs so Rails knows to use the RJS renderer to
render it into the page. Might be as simple as that.

Best regards

Peter De Berdt