Created
March 11, 2013 21:10
-
-
Save toots/5137788 to your computer and use it in GitHub Desktop.
Node-webkit: pop out a "save as" dialog with a given default name to save the given data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
saveAs: (name, data) -> | |
blob = new Blob [data] | |
url = URL.createObjectURL blob | |
# HTML5, jQuery, WebKit.. you all SUCK! | |
# (feels better now!) | |
$("<a>").attr(href: url, download: name).get()[0].click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Romain: is this odd because the element is not actually attached to the DOM when you're doing the click? I wonder if you stuck it in the dom you wouldn't need the odd .get()[0] pain.