Forum: Ruby on Rails ajax question about refreshing divs

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.
Rodrigo D. (Guest)
on 2006-03-28 23:11
(Received via mailing list)
Ok, I have manny divs in the html, and I have a login form in a inner
div, if the user tries to login and the user/password is invalid, only
the inner div needs to be refreshed and show the user the error. If the
user/password is  ok, the main div needs to be refreshed.

How could I do this?



this is the view in example



<div id="MainDiv">

foo

  <div id="InnerDiv">

    <%= form_tag :action => "login" %>

      <%= text_field "user", "username", "size" => "20", "class" =>
"Textos-02" %>

      <%= text_field "user", "password", "size" => "20", "class" =>
"Textos-02" %>

      <%= image_submit_tag "bot-ok.gif" %>

    <% end_form_tag %>

  </div>

</div>



and this is the controller



class HomePageController < ApplicationController



  def login

    #More than 2 parameters means an post (there is always a post couse
it's ajax)

    if params.length == 2

            @user = User.new

    else

      if @user.username == "foo" && @user.password == "foo"

        logger.warn "loggin failed, refresh only InnerDiv and show the
error"

      else

        logger.warn "loggin failed, refresh MainDiv"

      end

    end

    #Show the page

    @headers["Content-Type"] = "text/html; charset=ISO8859-1"

    render :layout => false

  end



end









Rodrigo D.



Iplan Networks                Datos Personales

removed_email_address@domain.invalid       removed_email_address@domain.invalid

www.iplan.com.ar <http://www.iplan.com.ar/>
www.rorra.com.ar <http://www.rorra.com.ar/>

5031-6303                     15-5695-6027
This topic is locked and can not be replied to.