Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 693
r3plica Avatar asked Mar 27 '14 11:03

r3plica


1 Answers

It was being a n00b :)

I was using

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

but I should have been using

$(".fileinput").fileinput("clear");
like image 113
r3plica Avatar answered Oct 21 '22 14:10

r3plica