Solved

Rails Clear Textarea

Posted on 2014-03-31
1
573 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now