Forum: Ruby on Rails RJS - page object in helpers?

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.
Surendra S. (Guest)
on 2006-03-08 22:29
(Received via mailing list)
Hello,
  I am using RJS and Edge Rails and I was wondering if the page object
should
be available in helpers also.

For example if I have a helper function

  def update_flash_messages
    page.replace_html 'flash_messages', (show_flash_messages :textilize
=> true)
    page.visual_effect 'flash_messages', :appear
  end

and then in my RJS files I call
  update_flash_messages

But right now the above code _doesn't work_, rather I have to pass the
page
object as shown below:

  def update_flash_messages(page)
    page.replace_html 'flash_messages', (show_flash_messages :textilize
=> true)
    page.visual_effect 'flash_messages', :appear
  end

and RJS file
  update_flash_messages page

Notice the passing of `page' object. Will it not be convenient if Rails
does
it automatically.
Or am I missing something?

Thanks.
--
Surendra S.
http://ssinghi.kreeti.com, http://www.kreeti.com

,----
| Great wits are sure to madness near allied,
| And thin partitions do their bounds divide.
|
|     (John Dryden, Absalom and Achitophel, 1681)
`----
Rick O. (Guest)
on 2006-03-09 01:48
(Received via mailing list)
On 3/8/06, Surendra S. <removed_email_address@domain.invalid> wrote:
> Hello,
>   I am using RJS and Edge Rails and I was wondering if the page object should
> be available in helpers also.

Sure can, on the latest code in trunk, but you have to call them on
the page object:

class RjsController
  def rjs
    render :update do |page|
      page.update_flash_messages
    end
  end
end

module RjsHelper
  def update_flash_messages
    page.replace_html 'flash_messages', (show_flash_messages :textilize
=> true)
    page.visual_effect 'flash_messages', :appear
  end
end

--
Rick O.
http://techno-weenie.net
Surendra S. (Guest)
on 2006-03-09 09:45
(Received via mailing list)
"Rick O." <removed_email_address@domain.invalid> writes:

> On 3/8/06, Surendra S. <removed_email_address@domain.invalid> wrote:
>> Hello,
>>   I am using RJS and Edge Rails and I was wondering if the page object should
>> be available in helpers also.
>
> Sure can, on the latest code in trunk, but you have to call them on
> the page object:

Thanks Rick, I will upgrade to the latest code in trunk.

--
Surendra S.
http://ssinghi.kreeti.com, http://www.kreeti.com
Read the latest news at: http://news.kreeti.com
,----
| "War is Peace! Freedom is Slavery! Ignorance is Strength!"
|     -- Orwell, 1984, 1948
`----
This topic is locked and can not be replied to.