# EXTJS With Rails.. render partials into divs

**URL:** <https://www.ruby-forum.com/t/extjs-with-rails-render-partials-into-divs/174829>\
**Category:** Rails\
**Created:** [September 2, 2009, 7:55pm UTC](https://www.ruby-forum.com/t/extjs-with-rails-render-partials-into-divs/174829 "2009-09-02T19:55:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 2, 2009, 7:55pm UTC](https://www.ruby-forum.com/t/extjs-with-rails-render-partials-into-divs/174829/1 "2009-09-02T19:55:56Z")

</div>

Ok so I have been playing with extjs and rails for about a week and I  
feel I have made good progress. But I have gotten stuck. I have an  
extjs form that has a button that submits data to my login method. I  
want to have the controller update just a div in my page without  
reloading or redirecting the page. This works great if I use just an  
normal ruby on rails link\_to. However, when I use a extjs button and  
set the handler to call the controller the controller cannot render a  
partial. It just hangs.

So here is my exmple. I have a very simple forum:

[CODE] var simple = new Ext.FormPanel({  
labelWidth: 75, // label settings here cascade unless  
overridden  
url:‘save-form.php’,  
frame:true,  
title: ‘Sign In’,  
bodyStyle:‘padding:5px 5px 0’,  
width: 350,  
defaults: {width: 230},  
defaultType: ‘textfield’,

```
    items: [{
            fieldLabel: 'Screen Name',
            name: 'screen_name',
            allowBlank:false
        },{
          fieldLabel: 'Password',
          name: 'password'
        }
    ],

    buttons: [{
        text: 'Login',
        type: 'submit',
        handler: function(){
        simple.form.submit({url: '/users/login?format_ext_json',

```

waitMsg: ‘Authenticating…’});}  
},{  
text: ‘Cancel’

```
    }]
});[/CODE]

```

Then I have a users controller and inside that controller I have a  
method:

[CODE]  
def login  
logger.info(“test”)  
@title = “Log in to pinktomato”  
if request.get?  
@user = User.new(:remember\_me =\> remember\_me\_string)  
elsif param\_posted?(:screen\_name)  
@user = User.new()  
@user.screen\_name = params[:screen\_name]  
@user.password = params[:password]  
user = User.find\_by\_screen\_name\_and\_password  
(@user.screen\_name,@user.password)  
if user  
logger.info(“found user”)  
user.login!(session)  
@user.remember\_me? ? user.remember!(cookies) : user.forget!  
(cookies)  
flash[:notice] = “User #{user.screen\_name} logged in!”  
render :text =\> “I HOPE THIS SHOWS”

```
    else
      # Don't show the password in the view
      @user.clear_password!
      flash[:notice] = "Invalid screen name/password combination"
    end
  end

```

end[/CODE]The “render :text” never renders… It actually just hangs  
on the authenticating when u click the login button. What I am  
assuming is that possibly the controller has lost reference to the div  
it should update. Is this possile. Since when I use a regular link\_to  
command in rails the login method works fine. Only when called from  
the extjs form.

I have tried lost of stuff so far even

[CODE] respond\_to do |format|  
format.ext\_json { render(:update) {|page| page.replace\_html  
“home” ,:partial=\>“loggedIn”) } }

```
      end[/CODE]

```

I hope my problem makes sense. I cannot find reference to this  
anywhere. I downloaded the extjs scaffold and I took at look at the  
generated code because it does create a create method for the  
scaffold. However this pre generated scaffold just redirects the user.  
I don’t want the page to referesh. Is this my only choice?

[CODE] def create  
@site = Site.new(params[:site])

```
respond_to do |format|
  if @site.save
    flash[:notice] = 'Site was successfully created.'
    format.ext_json { render(:update) {|page| page.redirect_to

```

sites\_path } }  
else  
format.ext\_json { render :json =\> @site.to\_ext\_json(:success  
=\> false) }  
end  
end  
end[/CODE]Please any help would be appreciated…

Vince

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 2, 2009, 8:39pm UTC](https://www.ruby-forum.com/t/extjs-with-rails-render-partials-into-divs/174829/2 "2009-09-02T20:39:50Z")

</div>

I am getting a little further if I use

```
      respond_to do |format|
        format.ext_json { render(:update) {|page|

```

page.replace\_html “home”, :partial =\> “loggedIn”} }  
end

The partial loads, however the waiting message from the forum never  
goes away.  
It just hangs…
