Solved

Rails Clear Textarea

Posted on 2014-03-31
1
581 Views
Last Modified: 2014-04-03
Using Rails 4.  I have a text_area_tag with submit_tag to do a query.  I need to add a button to  clear out the textarea and resubmit the form (using form_tag)

Layout looks like this:
Textarea
Query Button 1   Clear Button

Code looks like this:
form_tag ....
    text_area_tag
    submit_tag  "Query Button"
end form tag

Any ideas?  Ajax was suggested.
0
Comment
Question by:lcor
1 Comment
 
LVL 10

Accepted Solution

by:
Andrew Doades earned 500 total points
ID: 39967378
Yif you're ok with waiting for a reply from the server, you can create a js.erb file that will be executed after the request. inferring from the form action, create a file called action_save.js.erb in the views folder and add:

$('#text_area_tag').val('');

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question