On the Node-Webkit web site (https://github.com/rogerwang/node-webkit/wiki/File-dialogs) it says to use the <Input type="file">
to bring up a file picker dialog, and then listen for the change
event to get the path and filename selected or specified.
This works fine the first time when I specify or select a file name, but if I bring up the file picker again and use the SAME file name, the change
event doesn't get fired! Only if I change the filename in the selector dialog does the change event fire. Below is an example:
<input id="export_file" type="file" nwsaveas style="display:none" nwworkingdir=""/>
<script>
var chooser = jQuery("#export_file");
chooser.change(function(evt)
{
alert(jQuery(this).val());
});
chooser.trigger('click');
</script>
Does anyone know a way to always fire an event after the user selects a file from the file picker (regardless if the file was previously picked or defined)?
Thanks.
Since your "handler" only gets called when the tag sees a change, you could reset it (after doing your handling -- alert call, in this case) so that every time is like the first time. If you "reset" the input tag, however, that fires a change event, so you need to (1)remove the change event listener, (2)reset the input tag to undefined and (3) restore the change event listener. Using the new node-webkit 0.7.0 File and Filelist constructors -- this will only work with v0.7.0 -- the following code should work.
<script>
var chooser = jQuery("#export_file");
function fileHandler (evt) {
alert(jQuery(this).val());
var f = new File('','');
var files = new FileList();
files.append(f);
chooser.unbind('change');
document.getElementById('export_file').files = files;
chooser.change(fileHandler);
}
chooser.change(fileHandler);
chooser.trigger('click');
</script>
Jonathan
"Windows Desktop App Creation with node-webkit"
Without seeing more of your code, I'll hazard a guess and suggest :
jQuery('#export_file').trigger('change');
Hope this helps,
Jonathan
"Windows App Creation with node-webkit"
The ember documentation states that there is a finally handler available on Promises: http://emberjs.com/api/classes/Ember.RSVP.Promise.html#method_finally However, using finally on a promise yields ...
The ember documentation states that there is a finally handler available on Promises: http://emberjs.com/api/classes/Ember.RSVP.Promise.html#method_finally However, using finally on a promise yields ...
In the options page of a chrome extension, localStorage is null and thus can not be used. Here are the files of the unpacked extension producing error. manifest.json { "name": "someTest", "...
In the options page of a chrome extension, localStorage is null and thus can not be used. Here are the files of the unpacked extension producing error. manifest.json { "name": "someTest", "...
I select an element of the page: $mainSection = $('#main'); then I add more Elements via AJAX into the <div id="main"></div> element. Next time I call $mainSection, the newly added ...
I select an element of the page: $mainSection = $('#main'); then I add more Elements via AJAX into the <div id="main"></div> element. Next time I call $mainSection, the newly added ...
I have built a website but really struggling with easyslider and Internet explorer. It seems the Javascript is loading and then deciding against it for some reason. jQuery is included in the header ...
I have built a website but really struggling with easyslider and Internet explorer. It seems the Javascript is loading and then deciding against it for some reason. jQuery is included in the header ...