# RJS - page object in helpers?

**URL:** <https://www.ruby-forum.com/t/rjs-page-object-in-helpers/78675>\
**Category:** Rails\
**Created:** [March 8, 2006, 9:29pm UTC](https://www.ruby-forum.com/t/rjs-page-object-in-helpers/78675 "2006-03-08T21:29:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![surendra\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@surendra\_s](https://www.ruby-forum.com/u/surendra_s)\
**Post date:** [March 8, 2006, 9:29pm UTC](https://www.ruby-forum.com/t/rjs-page-object-in-helpers/78675/1 "2006-03-08T21:29:55Z")

</div>

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://ssinghi.kreeti.com), [http://www.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)  
`----

---

<div class="post-metadata">

**Author:** ![surendra\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@surendra\_s](https://www.ruby-forum.com/u/surendra_s)\
**Post date:** [March 9, 2006, 12:48am UTC](https://www.ruby-forum.com/t/rjs-page-object-in-helpers/78675/2 "2006-03-09T00:48:25Z")

</div>

On 3/8/06, Surendra S. [removed\_email\_address@domain.invalid](mailto: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](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![surendra\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@surendra\_s](https://www.ruby-forum.com/u/surendra_s)\
**Post date:** [March 9, 2006, 8:45am UTC](https://www.ruby-forum.com/t/rjs-page-object-in-helpers/78675/3 "2006-03-09T08:45:52Z")

</div>

“Rick O.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> On 3/8/06, Surendra S. [removed\_email\_address@domain.invalid](mailto: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://ssinghi.kreeti.com), [http://www.kreeti.com](http://www.kreeti.com)  
Read the latest news at: [http://news.kreeti.com](http://news.kreeti.com)  
,----  
| “War is Peace! Freedom is Slavery! Ignorance is Strength!”  
| – Orwell, 1984, 1948  
`----
