# Problems with link\_to\_function----Help

**URL:** <https://www.ruby-forum.com/t/problems-with-link-to-function-help/142355>\
**Category:** Rails\
**Created:** [July 7, 2008, 8:12am UTC](https://www.ruby-forum.com/t/problems-with-link-to-function-help/142355 "2008-07-07T08:12:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [July 7, 2008, 8:12am UTC](https://www.ruby-forum.com/t/problems-with-link-to-function-help/142355/1 "2008-07-07T08:12:09Z")

</div>

Hi,

I am using link\_to\_remote to update part of the page. The new content  
that is going to replace the original one has javascript tabs. The  
problem is the javascript tabs doesn’t work in this situation. The tabs  
works fine when I use link\_to to navigate through pages. The javascript  
validation in the new content is working. Where did it went wrong?  
Someone please help.

Thanks.

…my\_view.rhtml(original content)…  
\<%= javascript\_include\_tag :defaults %\>

\<%= link\_to\_remote “Show Items”, :update =\> “operation\_panel”, :url =\>  
{:controller =\> “item”, :action =\> “index”, :id =\> item.id} %\>

…

…item.rhtml(new content)…  
\<%= javascript\_include\_tag “tabpane.js” %\>

## **Pass List**

```
<% for item in @item %>
<tr>

<%= link_to_remote item.name, :update => "operation_panel", :url =>

```

{:controller =\> “item”, :action =\> “items”, :id =\> item.id} %\>  
  
\<% end %\>

```
</div>

```

```
<script type="text/javascript">
    setupAllTabs();
    document.getElementById("item_tab").show();
</script>
```

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [July 7, 2008, 9:22am UTC](https://www.ruby-forum.com/t/problems-with-link-to-function-help/142355/2 "2008-07-07T09:22:11Z")

</div>

user splash wrote:

> Hi,
> 
> I am using link\_to\_remote to update part of the page. The new content  
> that is going to replace the original one has javascript tabs. The  
> problem is the javascript tabs doesn’t work in this situation. The tabs  
> works fine when I use link\_to to navigate through pages. The javascript  
> validation in the new content is working. Where did it went wrong?  
> Someone please help.
> 
> > > >

Hi,

Sorry my mistake. This problem doesnt happen to my link\_to\_remote. The  
above problem is happening to my javascript tree menu. When the link is  
clicked, the tabs are not showing. Where did it went wrong? How can I  
write a javascript that resembles link\_to\_remote? Please help

Thanks

…tree menu…

function ajax\_init() {

```
var myajax = new Ajax.Request;
return myajax;

```

}

function drawTree ( tree\_items ,div\_id ) {

```
new tree (tree_items , TREE_TPL, 

```

document.getElementById(‘profile\_tree\_panel’) );  
callbackfunction = get\_detail;  
}

function get\_detail( args ) {

```
var target_url = args.split('_')[0];
target_url = target_url.replace(/-/g,"_");
unknown_url = target_url.split('*');

var myajax = ajax_init();
switch(unknown_url[1])
{
    case "0":
        new_url = unknown_url[0] + "?name=0"
        break;
    case undefined:
        new_url = target_url
        break;
    case "Total":
        new_url = unknown_url[0] + "?name=1"
        break;
    case "Site":
        new_url = unknown_url[0] + "?name=2"
        break;
    default:
        new_url = unknown_url[0] + "?name=3"
}

 detail_response=document.getElementById('operation_panel').innerHTML

myajax.request(new_url);
myajax.transport.onreadystatechange = function() {

    if(myajax.transport.readyState == 4) {
    document.getElementById('operation_panel').innerHTML = 

```

myajax.transport.responseText  
}

```
    }
}
```

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [July 7, 2008, 9:57am UTC](https://www.ruby-forum.com/t/problems-with-link-to-function-help/142355/3 "2008-07-07T09:57:14Z")

</div>

On Jul 7, 8:22 am, user splash [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,
> 
> Sorry my mistake. This problem doesnt happen to my link\_to\_remote. The  
> above problem is happening to my javascript tree menu. When the link is  
> clicked, the tabs are not showing. Where did it went wrong? How can I  
> write a javascript that resembles link\_to\_remote? Please help

Easiest way is probably to look at what link\_to\_remote generates and  
copy that.

Fred

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [July 7, 2008, 10:58am UTC](https://www.ruby-forum.com/t/problems-with-link-to-function-help/142355/4 "2008-07-07T10:58:29Z")

</div>

Frederick C. wrote:

> On Jul 7, 8:22ï¿½am, user splash [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Hi,
> > 
> > Sorry my mistake. This problem doesnt happen to my link\_to\_remote. The  
> > above problem is happening to my javascript tree menu. When the link is  
> > clicked, the tabs are not showing. Where did it went wrong? How can I  
> > write a javascript that resembles link\_to\_remote? Please help
> 
> Easiest way is probably to look at what link\_to\_remote generates and  
> copy that.
> 
> Fred

Thanks. I have copied what link\_to\_remote generates and it now works.
