Solved

Rails Clear Textarea

Posted on 2014-03-31
1
604 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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 …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

730 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