# Help in AJAX page using partials

**URL:** <https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249>\
**Category:** Rails\
**Created:** [July 5, 2008, 6:55am UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249 "2008-07-05T06:55:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rocknrollcar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rocknrollcar](https://www.ruby-forum.com/u/rocknrollcar)\
**Post date:** [July 5, 2008, 6:55am UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249/1 "2008-07-05T06:55:53Z")

</div>

Hi. I am doing a web project for my school. I have models like Forum,  
Student, Event, Teacher, etc. Users are allowed to go to these models  
only after logging in so that they can view and update their details,  
create events, topics in forums, etc.  
My page has a header, a menu bar, a content-container and a footer  
in the page. The content container has a left sidebar and a content div  
to contain the rendered content. The left side bar has links to Forum,  
Student, Event, Teacher, etc inside a partial.This is contained in the  
main layout. Everything is going fine. What i need to know is how can i  
implement the same layout with only refreshing the content div and not  
the entire page without using rjs(i can use Prototype javascript  
library).

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rocknrollcar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rocknrollcar](https://www.ruby-forum.com/u/rocknrollcar)\
**Post date:** [July 5, 2008, 8:36am UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249/2 "2008-07-05T08:36:27Z")

</div>

On Sat, Jul 5, 2008 at 2:55 PM, Rock R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> the entire page without using rjs(i can use Prototype javascript  
> library).

You need to research and learn about AJAX requests.

The function you are going to use for prototype is ‘new  
Ajax.request(‘url…’)’

Go read up on this at [Prototype API Documentation | Ajax.Request (Deprecated URL)](http://www.prototypejs.org/api/ajax/request)

Mikel

–

> **[Mikel Lindsaar](https://lindsaar.net/)**
>
> Internet Home for Mikel Lindsaar

Rails, RSpec and Life blog…

---

<div class="post-metadata">

**Author:** ![rocknrollcar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rocknrollcar](https://www.ruby-forum.com/u/rocknrollcar)\
**Post date:** [July 5, 2008, 8:41am UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249/3 "2008-07-05T08:41:44Z")

</div>

Mikel L. wrote:

> On Sat, Jul 5, 2008 at 2:55 PM, Rock R.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > the entire page without using rjs(i can use Prototype javascript  
> > library).
> 
> You need to research and learn about AJAX requests.
> 
> The function you are going to use for prototype is ‘new  
> Ajax.request(‘url…’)’
> 
> Go read up on this at [Prototype API Documentation | Ajax.Request (Deprecated URL)](http://www.prototypejs.org/api/ajax/request)
> 
> Mikel
> 
> –  
> [http://lindsaar.net/](http://lindsaar.net/)  
> Rails, RSpec and Life blog…

Thanks for your reply. I know about implementing AJAX using rails using  
the prototype helpers. But i want to use a single page for accessing  
Forum,  
Student, Event, Teacher, etc with only the respective view templates for  
the CRUD actions, appearing in the content area without complete page  
refresh.

---

<div class="post-metadata">

**Author:** ![rocknrollcar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rocknrollcar](https://www.ruby-forum.com/u/rocknrollcar)\
**Post date:** [July 5, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249/4 "2008-07-05T14:21:04Z")

</div>

Rock R. wrote:

> Thanks for your reply. I know about implementing AJAX using rails using  
> the prototype helpers. But i want to use a single page for accessing  
> Forum,  
> Student, Event, Teacher, etc with only the respective view templates for  
> the CRUD actions, appearing in the content area without complete page  
> refresh.

The only way to do it without a page refresh is via AJAX, so you will  
need to either (1) use an existing library which makes this easier  
(Prototype, JQuery, or something else), or (2) reinvent the wheel and  
write all of the JavaScript yourself.

Peace,  
Phillip

---

<div class="post-metadata">

**Author:** ![rocknrollcar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rocknrollcar](https://www.ruby-forum.com/u/rocknrollcar)\
**Post date:** [July 5, 2008, 8:51am UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249/5 "2008-07-05T08:51:06Z")

</div>

On Sat, Jul 5, 2008 at 4:41 PM, Rock R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Mikel L. wrote:  
> Thanks for your reply. I know about implementing AJAX using rails using  
> the prototype helpers. But i want to use a single page for accessing  
> Forum,  
> Student, Event, Teacher, etc with only the respective view templates for  
> the CRUD actions, appearing in the content area without complete page  
> refresh.

Yes, you can absolutely do this. I did it on an app. Only one page  
and then all parts refreshing as you go.

It gets messy though.

You are better off doing the request response thing. For one thing,  
the back button works again 🙂

Mikel

–

> **[Mikel Lindsaar](https://lindsaar.net/)**
>
> Internet Home for Mikel Lindsaar

Rails, RSpec and Life blog…

---

<div class="post-metadata">

**Author:** ![rocknrollcar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rocknrollcar](https://www.ruby-forum.com/u/rocknrollcar)\
**Post date:** [July 5, 2008, 2:27pm UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249/6 "2008-07-05T14:27:39Z")

</div>

On 05 Jul 2008, at 14:21, Phillip K. wrote:

> need to either (1) use an existing library which makes this easier  
> (Prototype, JQuery, or something else), or (2) reinvent the wheel and  
> write all of the JavaScript yourself.

… or worship the devil and resort to iframes.

---

<div class="post-metadata">

**Author:** ![rocknrollcar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f14d63/32.png) [@rocknrollcar](https://www.ruby-forum.com/u/rocknrollcar)\
**Post date:** [July 5, 2008, 2:29pm UTC](https://www.ruby-forum.com/t/help-in-ajax-page-using-partials/142249/7 "2008-07-05T14:29:43Z")

</div>

Peter De Berdt wrote:

> … or worship the devil and resort to iframes.

Heh heh 🙂

I’ve always avoided iframes like the plague (and the devil 😉 ), so that  
possibility didn’t cross my mind.

Thanks Peter!

Phillip
