My limited knowledge of JavaScript may be one reason why I’m wondering how to properly use a callback function in require( “ko/dialogs” ) and be able to do something with the chosen file. When writing some Firefox and Chrome extensions recently, the canonical way to do callbacks was apparently in the form of an anonymous function, and that always worked fine. But I’m not sure how to do it with the Komodo IDE SDK. Here was my first try:
var d = require( "ko/dialogs" );
d.filepicker( "title", function() { alert( "callback was called" ); }, {} );
A function variable (my apologies if I am misremembering the term) behaves the same:
var f = function() { alert( "callback was called" ); };
d.filepicker( "title", f, {} );
Both techniques result in a file selection dialog. But if a file is chosen and the “Ok” button is clicked, the dialog box does not go away. To make it go away, one must click the “Cancel” button and thus no file is chosen. Either way, I’m not sure what the callback function should look like in order to process the file, assuming one can get the dialog box to work. Any ideas?