Forum: Ruby on Rails ajax insertion into a form

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.
92965416368b1e311907226abdcfac68?d=identicon&s=25 Pierre Gambarotto (Guest)
on 2006-02-02 10:53
(Received via mailing list)
After an ajax insertion in the dom, it seems the browser don't
refresh its knowledge of the page.

The source of the page is identical after the insertion, whereas the
display is correct.

The ajax insertion is used to add an input field. The added fields
are ignored by the submission of the form.

Isn't it possible to do that, or maybe there's a problem in my code ?


The view :

new.rhtml
<%= start_form_tag :action => 'create' %>
   <%= render_partial 'form' %>
   <p><label for="telephone">Telephone</label>

    <%= link_to_remote("Add a number",
                        :url=>{:action=>'new_tel'},
                         :update =>'telephone', :position=> :after)
     %>
    <br/>
<%= text_field_tag 'telephone' %></p>
<%= submit_tag "Create" %>
<%= end_form_tag %>

The controller :
def new
    session[:num_tels]=0
end

def new_tel
    @tel_num=session[:num_tels]
     @tel_num=@tel_num.succ
     session[:num_tels]=@tel_num
     render (:text=>"<br/>"+@tel_num.to_s+'<input
id="telephone"'+@tel_num.to_s+' name="telephone"+@tel_num.to_s
type="text" />')
end
5ceea097a3b29cb6a5da6705926410f4?d=identicon&s=25 Gerret Apelt (Guest)
on 2006-02-02 11:03
(Received via mailing list)
You mean that the display of your page changes as expected, but when
you do a "view source", the new input field isnt visible in the
source?

The browser's "view source" will display the page source as
downloaded, and not as inferred from the DOM. If you want to view an
HTML version of the current DOM (say, after your AJAX update), I
recommend the Aardvark plugin for firefox. It lets you select any
container on the page (like your form element), and view its source as
inferred from the DOM.

cheers
Gerret
92965416368b1e311907226abdcfac68?d=identicon&s=25 Pierre Gambarotto (Guest)
on 2006-02-02 17:22
(Received via mailing list)
Le 2 févr. 06 à 11:01, Gerret Apelt a écrit :

>
Thanks, great tool ! And of course the glitch was in my code ^^
http://www.karmatics.com/aardvark/
D2eecb3df7da359aa6f6559fddc39945?d=identicon&s=25 Damon Hill (Guest)
on 2006-02-02 19:08
(Received via mailing list)
Man, I was sooooo looking foward to this Aardvark plug-in.
However, it appears it is not compatible with FF 1.5.0.1 (which my FF
was
automatically updated with last night).

:(

Oh well, maybe soon???

~damon
Ac1da5d66d51a1c3b843221032247b30?d=identicon&s=25 Eric Goodwin (Guest)
on 2006-02-02 19:26
(Received via mailing list)
Hi Damon,

Here is a great firefox extension for viewing the rendered source.

http://jennifermadden.com/scripts/ViewRenderedSource.html

Also if you want to see your ajax requests, it would suggest Julien
Couvreur's greasemonkey script at:

http://blog.monstuff.com/archives/images/XMLHttpRe...

Hope this can help out,
Eric


Damon Hill wrote:
> On 2/2/06, *Pierre Gambarotto* <pierre.gambarotto@enseeiht.fr
>     > The browser's "view source" will display the page source as
>
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Eric Goodwin
http://www.ericgoodwin.com
This topic is locked and can not be replied to.