views:

78

answers:

2

Hi i have the rails application. when i call the home controller i have index action . in the index.html.erb .i have some link_to_remote links.

<li><%=link_to_remote "Example",
  :update =>'view',
  :url =>{:controller => 'home',:action => 'bank'},
  :method => :post,
  :html =>{:id =>"cb"},
  :with => "'choose=' +encodeURIComponent('value')" %></li>


<li><%=link_to_remote "Test",
  :update =>'view',
  :url =>{:controller => 'home',:action => 'bank'},
  :method => :post,
  :html => { :id =>'cb1'},
  :with => "'choose=' +encodeURIComponent('value')" %></li>

After clicking the "Example" and "Test" option the respective div got updated .... i want to highlighting the options after user click happened... consider If "Example" clicked i want to highlight "Example" option background...

I tried with current_page? rails helper method, :complete attribute of link_to_remote but no luck can any one please suggest me on this. ... Thanks in advance

A: 

there are params[:controller] and params[:action] that help you to know which action is current.

shingara
Yes if i use params[:action] means it returns "index" action only instead of current action ....
palani
A: 
<div id='example_link'>
  <%= link_to_remote "Example",
      :update =>'view',
      :url =>{:controller => 'home',:action => 'bank'},
      :method => :post,
      :html =>{:id =>"cb"},
      :with => "'choose=' +encodeURIComponent('value')" %>
</div>

in your home controller

def bank
  # your code
  render :update do |page|
    page << "$('#example_link').addClass('highlighted')"
  end
end

in css

.highlighted{
  background-color: yellow;
}
fl00r
Thanks for your response.... under the :update attribute the update the "View" div... how should i change that according to you example. can you please give detailed syntax on that please
palani
I've updated my answer
fl00r
Hey Thank you so much for you detailed answer... i appreciate that... its really helpfull for me... thanks a lot... can you please suggest me how should i highlight "Example" link option too.. after it clicked??
palani