简体   繁体   中英

Clear textarea after using formRemote in grails

I've tried lots of stuffs already but It fails

$('#field')[0].reset();

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

document.getElementById("field").value = "";

Everything doesn't work, is there something wrong with formRemote?

edit:

<g:formRemote class="ui reply form" name="entryForm"url="[controller: 'game', action: 'addReview']" update="review">
<input" id="reviewButton" type="submit" value="Add Review" />

You aren't selecting the element correctly; in the statement:

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

The #field refers to an element with an id of field ( id="field" ), which based on your posted gsp element would not be the case. In a formRemote, when the id is omitted the name value is used as the id as well (at least according to documentation). You could use:

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

Or assign an id to your formRemote, which I find more explicit and less grails magic.

Keep in mind, I'm fairly certain that formRemote is deprecated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM