You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to implement save to backend as per issue #73. However, I ran into some errors:
When I try using the .start() method instead of the init() method, I get the following error: Missing initialization hash, redirecting to main entrypoint
and tracked it back to this error: Error: Unable to process binding "template: function(){return 'main' }"
Message: Cannot find template with ID main
My code is as follows:
plugins = [
// plugin for integrating save button
function (viewModel) {
var saveCmd = {
name: 'Save',
enabled: ko.observable(true)
};
saveCmd.execute = function () {
saveCmd.enabled(false);
viewModel.metadata.changed = Date.now();
if (typeof viewModel.metadata.key == 'undefined') {
var rnd = Math.random().toString(36).substr(2, 7);
viewModel.metadata.key = rnd;
}
// This is the simplest for sending it as POST
var postData = {
//csrf_token: 'yourCsrfValueHere', // this is only required if your back-end requires csrf token
metadata: viewModel.exportMetadata(),
content: viewModel.exportJSON(),
html: viewModel.exportHTML()
};
$.post('/mosaico/save', postData)
.done(function () {
viewModel.notifier.success(viewModel.t('Successfully saved.'));
})
.fail(function (jqXHR, textStatus, error) {
console.log(textStatus);
console.log(error);
console.log(jqXHR);
viewModel.notifier.error(viewModel.t('Saving failed. Please try again in a few moments or contact us.'));
})
.always(function () {
saveCmd.enabled(true);
});
};
viewModel.save = saveCmd;
},
];
var ok = Mosaico.start({
imgProcessorBackend: basePath + '/img/',
emailProcessorBackend: basePath + '/dl/',
titleToken: "MOSAICO Responsive Email Designer",
//onSave: function (saveObject) { alert('hi'); },
fileuploadConfig: {
url: basePath + '/upload/'
}
}, '/templates/versafix-1/template-versafix-1.html', undefined, undefined, plugins);
Any help much appreciated
The text was updated successfully, but these errors were encountered:
If you use start you can't check the return value as start doesn't return false or true.
So your editor.html will always tell you "Missing initialization hash, redirecting to main entrypoint"
I was trying to implement save to backend as per issue #73. However, I ran into some errors:
When I try using the
.start()
method instead of theinit()
method, I get the following error:Missing initialization hash, redirecting to main entrypoint
and tracked it back to this error:
Error: Unable to process binding "template: function(){return 'main' }"
Message: Cannot find template with ID main
My code is as follows:
Any help much appreciated
The text was updated successfully, but these errors were encountered: