RJS template problem!


#1

hi all,

i have the following controller:

class UserController < ApplicationController
.
.
.
def login
@user = User.new(params[:user])
@logged_in_user = @user.try_to_login
if @logged_in_user
session[:user_id] = @logged_in_user.id
else
flash[:notice] = “ungültige Daten!”
end
end
.
.
.
end

with this rjs template:
login.rjs:

if @logged_in_user
page.replace_html ‘content’, ‘welcome!’
page.replace_html ‘nav’, :partial => “ascase/navi”
else
page.replace_html ‘content’, :partial => ‘loginform’
page.visual_effect :highlight, ‘notice’, :duration => 2
flash[:notice] = “”
end

and my loginform partial:

Login

<%= flash[:notice] %>
<%= form_remote_tag :url => {:action => 'login'}%>
<p>
<label for="user_nickname">Benutzername</label><br/>
<%= text_field 'user', 'nickname'  %><br/>
<label for="user_password">Passwort</label><br/>
<%= password_field 'user', 'password_plain' %>
</p>

<%= submit_tag “Login” %>
<%= end_form_tag %>

my problem is that i always have to click on the “Login” button twice so
that the “content” and “nav” div are going to replaced.
what can i do to get this with a simple click on “Login” ?

thanks


#2

ok, i got it working now.
i have just forgot to give the navi partial an object which is used in
_navi.rhtml