I have been trying to understand what Flinn said in
http://www.actsasflinn.com/Ajax_Tabs/index.html#
{{Problem }}
I don''t understand how to pass the instance variable to the partial.
in the main html "url_for(:action => ''test'')"
does not seem to pass
the instance @test to the partial. output is ###.
{{CODE}}
{{in main html.erb}}
<ul class="tabselector" id="tabcontrol1">
<li class="tab-selected" id="vendor_tab">
<%= link_to_function(''Vendor'',
"loadPane($(''part_pane''), ''" +
url_for(:action => ''test'') +
"''),tabselect($(''vendor_tab''));
paneselect($(''vendor_pane''))") %></li>
</ul>
<ul class="panes" id="panecontrol1">
<li id="vendor_pane" class="pane-selected">
<%= render :partial => ''test'', :object => @groceries
%>
<div id="ss"></div>
</li>
<ul>
{{CONTROLLER}}
def test
@test = "3"
respond_to do |format|
format.html
format.js {
render :update do |page|
page.replace_html ''ss'', :partial =>
''test''
end
}
format.xml { render :xml => @test.to_xml }
end
end
{{partial}}
test is <%= @test%>
{{JS library}}
function tabselect(tab) {
var tablist =
$(''tabcontrol1'').getElementsByTagName(''li'');
var nodes = $A(tablist);
var lClassType = tab.className.substring(0,
tab.className.indexOf(''-'') );
nodes.each(function(node){
if (node.id == tab.id) {
tab.className=lClassType+''-selected'';
} else {
node.className=lClassType+''-unselected'';
};
});
}
function paneselect(pane) {
var panelist =
$(''panecontrol1'').getElementsByTagName(''li'');
var nodes = $A(panelist);
nodes.each(function(node){
if (node.id == pane.id) {
pane.className=''pane-selected'';
} else {
node.className=''pane-unselected'';
};
});
}
function loadPane(pane, src) {
if (pane.innerHTML=='''' || pane.innerHTML==''<img
alt="Wait" src="/
images/spinner.gif" style="vertical-align:-3px" />
Loading...'') {
reloadPane(pane, src);
}
}
function reloadPane(pane, src) {
new Ajax.Updater(pane, src, {asynchronous:1, evalScripts:true,
onLoading:function(request){pane.innerHTML=''<img
alt="Wait" src="/
images/spinner.gif" style="vertical-align:-3px" />
Loading...''}})
}
{{test.js.rjs}}
page.replace_html("ss", :partial => "test", :object =>
@test)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Aug-26 09:21 UTC
Re: AJAX tabs cannot pass instance variable to partial
On 26 Aug 2008, at 10:14, tyliong wrote:> > I have been trying to understand what Flinn said in > http://www.actsasflinn.com/Ajax_Tabs/index.html# > > {{Problem }} > > I don''t understand how to pass the instance variable to the partial. > in the main html "url_for(:action => ''test'')" does not seem to pass > the instance @test to the partial. output is ###. >Are you expecting the value of @test at the point that main.html.erb to be preserved until when your ajax request is handled ? Fred> >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
no i got desperate and was just trying to any tactic i knew to get the instance to the partial. i am trying to push the value from the controller to the partial. basically the @test = 3. btw if u guys know of an easier ajax tab method please tell me as well On Aug 26, 5:21 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 26 Aug 2008, at 10:14, tyliong wrote: > > > > > I have been trying to understand what Flinn said in > >http://www.actsasflinn.com/Ajax_Tabs/index.html# > > > {{Problem }} > > > I don''t understand how to pass the instance variable to the partial. > > in the main html "url_for(:action => ''test'')" does not seem to pass > > the instance @test to the partial. output is ###. > > Are you expecting the value of @test at the point that main.html.erb > to be preserved until when your ajax request is handled ? > > Fred > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---