Problems with link_to_function----Help

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} %>

<div id='operation_panel'></div>

....................................................

.............item.rhtml(new content)......................
<%= javascript_include_tag "tabpane.js" %>

<div class="tab-pane" id="tab-pane-1">

   <script type="text/javascript">
       var tabPane1 = new WebFXTabPane( document.getElementById(
"tab-pane-1" ) );
   </script>

   <div class="tab-page" id="item_tab">
      <h2 class="tab"><b>Pass List</b></h2>

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

    <%= link_to_remote item.name, :update => "operation_panel", :url =>
{:controller => "item", :action => "items", :id => item.id} %><br/>
    <% end %>

    </div>
</div>

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

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
            }

        }
    }

Easiest way is probably to look at what link_to_remote generates and
copy that.

Fred

Frederick Cheung wrote: