Simulate click on input in mobile
I'm trying to covert over some code to work in mobile browsers, Note: have jQuery Mobile Events in the page.
The html:
- <input type="file" id="importfile" style="display:none;"><button id="import" > Import</button>
The orig script:
- $("#import").click(function() {
- document.getElementById("importfile").click();
- });
New script:
- $('#import').on('singletap', function() {
- console.log('Import Button Hit'); // fires ok
- console.log('Importfile: ' , $('#importfile')); // shows correct input element
- $('#importfile').trigger('singletap');
- });
It's giving me the logs, but never simulates the click on #importfile. What do I need to change?