Hi all,
I tried to use ajax in a simple eshop application, but the
page.replace_html fail in strange mode.
Controller code:
class mycontroller < ApplicationController
Some code
def login
# Check user existence in db
# if the user exist replace the login form with the user menu'
class mycontroller < ApplicationController
Some code
def login
# Check user existence in db
# if the user exist replace the login form with the user menu'
if session[:user] != nil
create_user_menu
end
end
def create_user_menu
@user = session[:user]
render :update do |page|
page.replace_html "login", :partial => 'user_menu', :locals
=> { :user => @user }
page.visual_effect :highlight, “login”
end
end
end
Layout code:
The partial _login.rhtml code:
<%= start_form_tag({:action => ‘login’}, {:name => ‘form_login’}) %>
<%= render :partial => ‘login_form’ %>
<%= link_to_function(“Login”, “document.form_login.submit()”)
%>
<%= end_form_tag %>
The partial _user_menu.rhtml contain only a simple html table.
When i click on “Login” link, the browser show a new page with
my_controller/login action and the code generted by the js helper,
instead the correct user menu in the page my_controller.
Where is the error?
Thanks in advance, Emiliano.