Solved

Rails Clear Textarea

Posted on 2014-03-31
1
566 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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
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 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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now