# Display result without reloading page

**URL:** <https://www.ruby-forum.com/t/display-result-without-reloading-page/131029>\
**Category:** Rails\
**Created:** [March 5, 2008, 11:21am UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029 "2008-03-05T11:21:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 5, 2008, 11:21am UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/1 "2008-03-05T11:21:32Z")

</div>

Hi all…

I have a tabbed interface for showing the details of an Item. By  
default the ‘Details’ tab is selected. The code for displaying each tab  
is in a partial file.

In one tab named ‘status’, i’m showing the list of status history of  
that item. I am trying to implement pagination for this list.  
When i click on the ‘next’ link to view the next page, the entire page  
get reloaded and return to ‘Details’ tab which is selected by default. I  
just want to display the next page in the ‘status’ tab without  
reloading.

How can i do this? Please help.

Thanks in advance  
Suneeta

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 5, 2008, 11:43am UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/2 "2008-03-05T11:43:34Z")

</div>

Hi,  
By default, the link tag will post the page. In your case, the  
pagination value (i.e.) the page number will be sent by GET method. I  
hope you can see the page variable in the URL.  
Coming to your problem, i am sure you should have some flag variable to  
differentiate between each tabs. So try to post (POST or GET method)  
that variable through java script from the Link tag.  
Hope it resolves your problem.

Regards,  
VASANTH

Suneeta Km wrote:

> Hi all…
> 
> I have a tabbed interface for showing the details of an Item. By  
> default the ‘Details’ tab is selected. The code for displaying each tab  
> is in a partial file.
> 
> In one tab named ‘status’, i’m showing the list of status history of  
> that item. I am trying to implement pagination for this list.  
> When i click on the ‘next’ link to view the next page, the entire page  
> get reloaded and return to ‘Details’ tab which is selected by default. I  
> just want to display the next page in the ‘status’ tab without  
> reloading.
> 
> How can i do this? Please help.
> 
> Thanks in advance  
> Suneeta

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 5, 2008, 12:01pm UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/3 "2008-03-05T12:01:29Z")

</div>

Hi,

The link tag are:

| \<%= link\_to('Previous', {:params =\> params.merge('page' =\> @hardware\_ci\_status\_histories\_pages.current.previous)}) if @hardware\_ci\_status\_histories\_pages.current.previous %\> \<%= pagination\_links(@hardware\_ci\_status\_histories\_pages,{:params =\> params.merge('ci'=\>@ci.id)}) %\> \<%= '' if @hardware\_ci\_status\_histories\_pages.current.previous and @hardware\_ci\_status\_histories\_pages.current.next %\> \<%= link\_to('Next', {:params =\> params.merge('page' =\> @hardware\_ci\_status\_histories\_pages.current.next)}) if @hardware\_ci\_status\_histories\_pages.current.next %\> |

I have an id for differentiating each tab. The id for the ‘status’ tab  
is ‘cistatushistory’. Can you please show me how to pass this id through  
javascript from the link tag?

Thank you for your reply  
Regards  
Suneeta

Vasanthakumar C. wrote:

> Hi,  
> By default, the link tag will post the page. In your case, the  
> pagination value (i.e.) the page number will be sent by GET method. I  
> hope you can see the page variable in the URL.  
> Coming to your problem, i am sure you should have some flag variable to  
> differentiate between each tabs. So try to post (POST or GET method)  
> that variable through java script from the Link tag.  
> Hope it resolves your problem.
> 
> Regards,  
> VASANTH
> 
> Suneeta Km wrote:
> 
> > Hi all…
> > 
> > I have a tabbed interface for showing the details of an Item. By  
> > default the ‘Details’ tab is selected. The code for displaying each tab  
> > is in a partial file.
> > 
> > In one tab named ‘status’, i’m showing the list of status history of  
> > that item. I am trying to implement pagination for this list.  
> > When i click on the ‘next’ link to view the next page, the entire page  
> > get reloaded and return to ‘Details’ tab which is selected by default. I  
> > just want to display the next page in the ‘status’ tab without  
> > reloading.
> > 
> > How can i do this? Please help.
> > 
> > Thanks in advance  
> > Suneeta

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 6, 2008, 5:08am UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/4 "2008-03-06T05:08:34Z")

</div>

Hi,  
Thank you so much for your reply. I tried giving the id as parameter.  
But it didn’t show any diference. When we click on the ‘next’ link the  
page is reloaded and the ‘Detail’ tab is selected.

Should I use ajax calls here inorder to prevent the page from being  
reloaded?  
Any idea about this?

Regards  
Suneeta

Vasanthakumar C. wrote:

> Hi,  
> Try this  
> “:params =\> params.merge(‘ci’=\>@ci.id,‘id’=\>‘cistatushistory’)”  
> inside the Link tag.
> 
> Regards,  
> Vasanth

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 6, 2008, 5:14am UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/5 "2008-03-06T05:14:44Z")

</div>

Suneeta Km wrote:  
Hi,  
Thank you so much for your reply. I tried giving the id as parameter.  
But it didn’t show any diference. When we click on the ‘next’ link  
the  
page is reloaded and the ‘Detail’ tab is selected.  
With this id what are the operations to be made?  
Should I use ajax calls here inorder to prevent the page from being  
reloaded?  
Any idea about this?

Regards  
Suneeta

> Vasanthakumar C. wrote:
> 
> > Hi,  
> > Try this  
> > “:params =\> params.merge(‘ci’=\>@ci.id,‘id’=\>‘cistatushistory’)”  
> > inside the Link tag.
> > 
> > Regards,  
> > Vasanth

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 5, 2008, 12:57pm UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/6 "2008-03-05T12:57:01Z")

</div>

Hi,  
Try this  
“:params =\> params.merge(‘ci’=\>@ci.id,‘id’=\>‘cistatushistory’)”  
inside the Link tag.

Regards,  
Vasanth

Suneeta Km wrote:

> Hi,
> 
> The link tag are:
> 
> | \<%= link\_to('Previous', {:params =\> params.merge('page' =\> @hardware\_ci\_status\_histories\_pages.current.previous)}) if @hardware\_ci\_status\_histories\_pages.current.previous %\> \<%= pagination\_links(@hardware\_ci\_status\_histories\_pages,{:params =\> params.merge('ci'=\>@ci.id)}) %\> \<%= '' if @hardware\_ci\_status\_histories\_pages.current.previous and @hardware\_ci\_status\_histories\_pages.current.next %\> \<%= link\_to('Next', {:params =\> params.merge('page' =\> @hardware\_ci\_status\_histories\_pages.current.next)}) if @hardware\_ci\_status\_histories\_pages.current.next %\> |
> 
> I have an id for differentiating each tab. The id for the ‘status’ tab  
> is ‘cistatushistory’. Can you please show me how to pass this id through  
> javascript from the link tag?
> 
> Thank you for your reply  
> Regards  
> Suneeta

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 6, 2008, 6:34pm UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/7 "2008-03-06T18:34:47Z")

</div>

There is a very interesting discussion of tabs in Rails located here:  
[http://www.therailsway.com/2007/6/28/free-for-all-tab-helper-summary](http://www.therailsway.com/2007/6/28/free-for-all-tab-helper-summary)

On Mar 5, 5:21 am, Suneeta Km [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 6, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/display-result-without-reloading-page/131029/8 "2008-03-06T17:34:24Z")

</div>

Hi,  
In the onclick event of the tabs you will pass some variable right?  
Either to normal posting methods or AJAX calls. I suppose that variable  
would be “id”. If thats the case then use this condition before passing  
to posting methods or AJAX calls,  
if(params[:id])  
id = params[:id] # so ur ‘cistatushistory’ will be stored in ‘id’  
end

Regards,  
VASANTH

Suneeta Km wrote:

> Suneeta Km wrote:  
> Hi,  
> Thank you so much for your reply. I tried giving the id as parameter.  
> But it didn’t show any diference. When we click on the ‘next’ link  
> the  
> page is reloaded and the ‘Detail’ tab is selected.  
> With this id what are the operations to be made?  
> Should I use ajax calls here inorder to prevent the page from being  
> reloaded?  
> Any idea about this?
> 
> Regards  
> Suneeta
