randomizertech
randomizertech

Reputation: 2329

Grails: Using jQuery for clear form not working

I am using Grails and the first part I have is a search field.

I am using this to create the CLEAR button, but it is not working:

$("#clear").click(function() {
    $(':input','#container')
        .not(':button, :submit, :reset, :hidden')
        .val('')
        .removeAttr('checked')
        .removeAttr('selected');
    $("#container #ScommodityList").empty();
    $("#container #SagentList").empty();
});

Does anybody know what I could be doing wrong?? Maybe the :input part?? In Grails they are called g:textfield

Something like this, but using Grails would be perfect!

http://jsfiddle.net/EPcnR/3/

Any help would be greatly appreciated

Upvotes: 1

Views: 1764

Answers (1)

jAndy
jAndy

Reputation: 235962

To clear a form, you might want to use javascripts native .reset().

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

Upvotes: 2

Related Questions