Forum: Ruby on Rails RJS template problem!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Trung T. (Guest)
on 2006-01-29 20:46
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&uuml;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:
<h1>Login</h1>

<div id="notice"><%= flash[:notice] %></div>
<%= 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
Trung T. (Guest)
on 2006-01-29 23:01
ok, i got it working now.
i have just forgot to give the navi partial an object which is used in
_navi.rhtml
This topic is locked and can not be replied to.