Im trying to call a click on this newly created anchor:
$('.file-status').html("Finished downloading <a class='download' download href='#{fileEntry.toURL()}'>#{name}</a>")
$('.download').click()
But the click event is not called. Not sure why this is?
Im trying to force a download, not open the link in the browser. Like Dropbox does
EDIT
Here is the code, so its more clear:
fileEntry.createWriter ((fileWriter) ->
fileWriter.onwriteend = (e) ->
$('.file-status').html("Finished downloading <a class='download' download href='#{fileEntry.toURL()}'>#{name}</a>")
$('.download').trigger('click');
fileWriter.onerror = (e) ->
console.log "Write failed: " + e.toString()
fileWriter.write blob
), errorHandler
UPDATE:
So after understanding from the answers below that this is not really possible, except if the server sends the data to me with the header Content-disposition: attachment. But this seems to me like a realy bad solutions to pure HTML5 JS apps, that might be offline.
So I found this, that handles this super awesomely! It works great. Here is the link:
http://updates.html5rocks.com/2011/08/Saving-generated-files-on-the-client-side
Hope this helps someone that wants to do the same as I am sure there are many!