Search code examples
twitter-bootstrap-3jasny-bootstrap

Jasny Bootstrap can't clear the file after submission


I have some html like this:

<div class="fileinput fileinput-new" data-provides="fileinput">
    <div class="input-group">
        <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
        <span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new">Select file</span><span class="fileinput-exists">Change</span><input type="file" id="File" name="..."></span>
        <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
    </div>
</div>

When the form has been submitted I want to clear the file from the input, but I don't know how to do it.

Jansy says I can do it by calling .fileinput("clear") but that doesn't work. Has anyone done this before? If so, how do I clear it?

Cheers


Solution

  • It was being a n00b :)

    I was using

    $("input[type=file]").fileinput("clear")
    

    but I should have been using

    $(".fileinput").fileinput("clear");