-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hey, just wondering why its been set to POST to another server/webpage to return the JSON? Couldn't this be achieved in the JS like such:
onSaveItemToFileClicked: function (e) {
var sessionString = "",
fileName = "",
sessions = [];
fileName = string.substitute(this.config.fileNameTplForSession, e.item);
sessions.push(e.item);
sessionString = JSON.stringify(sessions);
this.downloadObjectAsJson(sessionString, fileName)
// // update form values
// this.saveToFileName.value = fileName;
// this.saveToFileContent.value = sessionString;
// // trigger the post to server side
// this.saveToFileForm.submit();
console.log('SaveSession :: onSaveItemToFileClicked :: end');
},
downloadObjectAsJson: function(exportObj, exportName){
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj));
var downloadAnchorNode = document.createElement('a');
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", exportName);
downloadAnchorNode.click();
downloadAnchorNode.remove();
},
khibma
Metadata
Metadata
Assignees
Labels
No labels