Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I trigger a double click with a single click in a form input[type="file"]?

I have a form input for submitting a file and I styled it because I didn't like the native style. Now, I have a single button that when clicked, it opens up the dialog to select the file. It works fine with a single click on Firefox and Chrome but it doesn't work in IE. The button needs a double click to open up the dialog in IE.

I have tried to trigger a double click with a single click using jQuery:

$("input").click(function() { 
    $(this).dblclick(); 
});

However, it doesn't seem to work. Is there any other approach to trigger a double click for IE?

Here's the demo: http://jsfiddle.net/HAaFb/

like image 528
otinanai Avatar asked Mar 11 '13 16:03

otinanai


1 Answers

What about something like this:

var count=0;
$("input").click(function(e) { 
    count++;
    if(count==2){
         count=0;
    }else{
        e.preventDefault();
    }
});

DEMO: http://jsfiddle.net/HAaFb/1/

http://jsbin.com/ukotit/17/edit

like image 146
Dom Avatar answered Sep 21 '22 23:09

Dom