I''m trying to put together a basic blog application for fun, and
I''m
using an RJS template to insert a new comment into existing comments.
The comment data is inserted, but the comment form at the bottom of the
page still contains the comment. I tried to clear out the text from the
form this way:
page.insert_html :top, ''comments'', :partial =>
''show_comment''
page.replace_html ''blog_entry_comment_body'',
''''
page.replace_html ''blog_entry_comment_subject'',
''''
But this doesn''t work either. Any thoughts on how to clear out the
form
contents after the comment is added? The form looks like this:
<% form_remote_tag(:url => {:action =>
''ajax_add_comment'', :controller
=> ''Comment'', :id => @blog_entry.id }) do %>
<%= render :partial=>"comment/form" %>
<%= submit_tag ''Add Comment'' %>
<% end %>
Firefox may also be putting the data in the form, as part of it''s
auto-completion functionality, I suppose. Same behavior is present in
IE7.
Thanks in advance,
Kevin
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> page.replace_html ''blog_entry_comment_body'', '''' > page.replace_html ''blog_entry_comment_subject'', ''''this isn''t doing what you think it is doing. it replaces the contents of tags, not the values. (actually, replace_html will work on a textarea, but will not on type="text" input) you want to do something like: # blog_entry_comment_body => textarea page << "$(''blog_entry_comment_body'').value = ''''" # also works #page.replace_html(''blog_entry_comment_body'', '''') # blog_entry_comment_subject => input type="text" page << "$(''blog_entry_comment_subject'').value = ''''" you are submitting the form via ajax, so therefore the page is not being ''reloaded'' and thus firefox or IE is not auto-filing the forms for you at this point because you never left the page. On 2/27/07, Kevin Tambascio <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m trying to put together a basic blog application for fun, and I''m > using an RJS template to insert a new comment into existing comments. > The comment data is inserted, but the comment form at the bottom of the > page still contains the comment. I tried to clear out the text from the > form this way: > > page.insert_html :top, ''comments'', :partial => ''show_comment'' > page.replace_html ''blog_entry_comment_body'', '''' > page.replace_html ''blog_entry_comment_subject'', '''' > > But this doesn''t work either. Any thoughts on how to clear out the form > contents after the comment is added? The form looks like this: > > <% form_remote_tag(:url => {:action => ''ajax_add_comment'', :controller > => ''Comment'', :id => @blog_entry.id }) do %> > > <%= render :partial=>"comment/form" %> > <%= submit_tag ''Add Comment'' %> > <% end %> > > Firefox may also be putting the data in the form, as part of it''s > auto-completion functionality, I suppose. Same behavior is present in > IE7. > > Thanks in advance, > Kevin > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can also use Collection Proxies in RJS like so :
page.select(''div textarea'').each do |element|
element.value=""
end
This takes all of the text areas in a div and replaces the value. You
could also use the div name like so :
page.select(''#id_of_textarea_here'').each do |element|
element.value=""
end
So if I had a <textarea id="id_of_textarea_here" ...
That should replace the value.
Hamza
On Feb 27, 2:27 pm, "Chris Hall"
<christopher.k.h...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> > page.replace_html ''blog_entry_comment_body'',
''''
> > page.replace_html ''blog_entry_comment_subject'',
''''
>
> this isn''t doing what you think it is doing. it replaces the
contents
> of tags, not the values. (actually, replace_html will work on a
> textarea, but will not on type="text" input)
>
> you want to do something like:
>
> # blog_entry_comment_body => textarea
> page << "$(''blog_entry_comment_body'').value =
''''"
> # also works
> #page.replace_html(''blog_entry_comment_body'',
'''')
>
> # blog_entry_comment_subject => input type="text"
> page << "$(''blog_entry_comment_subject'').value
= ''''"
>
> you are submitting the form via ajax, so therefore the page is not
> being ''reloaded'' and thus firefox or IE is not
auto-filing the forms
> for you at this point because you never left the page.
>
> On 2/27/07, Kevin Tambascio
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>
>
>
> > I''m trying to put together a basic blog application for fun,
and I''m
> > using an RJS template to insert a new comment into existing comments.
> > The comment data is inserted, but the comment form at the bottom of
the
> > page still contains the comment. I tried to clear out the text from
the
> > form this way:
>
> > page.insert_html :top, ''comments'', :partial =>
''show_comment''
> > page.replace_html ''blog_entry_comment_body'',
''''
> > page.replace_html ''blog_entry_comment_subject'',
''''
>
> > But this doesn''t work either. Any thoughts on how to clear
out the form
> > contents after the comment is added? The form looks like this:
>
> > <% form_remote_tag(:url => {:action =>
''ajax_add_comment'', :controller
> > => ''Comment'', :id => @blog_entry.id }) do
%>
>
> > <%= render :partial=>"comment/form" %>
> > <%= submit_tag ''Add Comment'' %>
> > <% end %>
>
> > Firefox may also be putting the data in the form, as part of
it''s
> > auto-completion functionality, I suppose. Same behavior is present in
> > IE7.
>
> > Thanks in advance,
> > Kevin
>
> > --
> > Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---