Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Rails Clear Textarea

Posted on 2014-03-31
1
Medium Priority
?
649 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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 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)
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…
Suggested Courses

597 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