# Updated DIV after submit

**URL:** <https://www.ruby-forum.com/t/updated-div-after-submit/80353>\
**Category:** Rails\
**Created:** [December 24, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353 "2006-12-24T20:11:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 24, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/1 "2006-12-24T20:11:52Z")

</div>

I have two DIV`s, one for menu(div “menu”), and other for appear the  
forms(div “tela”).Well, after execute submit of view “new”, is load the  
view of scaffold, in new window. I want that after execute the submit,  
the view “list” appear in my div “tela”.

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 24, 2006, 9:34pm UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/2 "2006-12-24T21:34:33Z")

</div>

Marcelo J. wrote:

> I have two DIV`s, one for menu(div “menu”), and other for appear the  
> forms(div “tela”).Well, after execute submit of view “new”, is load the  
> view of scaffold, in new window. I want that after execute the submit,  
> the view “list” appear in my div “tela”.

I am beginning to suspect that a Rails Ajax project should prefer  
“render :update” over :update =\> ‘id’. That means instead of the View  
RHTML containing…

remote\_something :update=\>‘my\_div’, …

we should prefer a controller action responding with:

render :update do |rjs| # some call that |page|  
rjs.replace\_html ‘my\_div’, my\_new\_html  
end

So you might be able to do this:

render :update do |rjs|  
rjs.replace\_html ‘my\_div’, my\_new\_html  
rjs.replace\_html ‘my\_list’, my\_new\_list  
end

Now the question arises how to extract my\_new\_html and my\_new\_list  
from scaffold-land.

And note that scaffolds should never be treated as production code  
(just as real-life scaffolds should never be treated as real  
buildings). You should learn from them, then write your own  
controllers and views.

Also note that you can update anything with contents, not just a DIV…

–  
Phlip  
[http://c2.com/cgi/wiki?ZeekLand](http://c2.com/cgi/wiki?ZeekLand) ← NOT a blog!!

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 24, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/3 "2006-12-24T22:07:02Z")

</div>

I make this render in controller, what make this?

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 24, 2006, 10:26pm UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/4 "2006-12-24T22:26:34Z")

</div>

Marcelo J. wrote:

> I make this render in controller, what make this?

I can’t understand your question. Copy a little of your code into your  
post and ask again, a different way.

–  
Phlip  
[http://c2.com/cgi/wiki?ZeekLand](http://c2.com/cgi/wiki?ZeekLand) ← NOT a blog!!

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 26, 2006, 3:10am UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/5 "2006-12-26T03:10:35Z")

</div>

Phlip wrote:

> Marcelo J. wrote:
> 
> > I make this render in controller, what make this?
> 
> I can’t understand your question. Copy a little of your code into your  
> post and ask again, a different way.
> 
> –  
> Phlip  
> [http://c2.com/cgi/wiki?ZeekLand](http://c2.com/cgi/wiki?ZeekLand) ← NOT a blog!!

I not have code, therefore I do not know I eat to start. I want loading  
one DIV after a submit. I like to make something as “link\_to\_remote”,  
together with submit it form.

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 26, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/6 "2006-12-26T14:13:58Z")

</div>

Well, I tried make the following:  
\<%= link\_to\_remote “Salvar”,{:update =\> “tela”, :url =\> {:controller  
=\> “cliente”, :action =\> “create”}},:class =\> “botao2” %\>

But return the message “validates\_presence\_of” of model of cliente. But  
the fields are correct.

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 27, 2006, 12:49am UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/7 "2006-12-27T00:49:41Z")

</div>

help

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [December 26, 2006, 12:28pm UTC](https://www.ruby-forum.com/t/updated-div-after-submit/80353/8 "2006-12-26T12:28:36Z")

</div>

help.
