0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Merge pull request #2097 from zacgeis/publishbutton-fix

Disable publish button until deffered is resolved
This commit is contained in:
Hannah Wolfe 2014-02-08 15:28:13 +00:00
commit 7151692c67

View file

@ -220,11 +220,22 @@
}, },
savePost: function (data) { savePost: function (data) {
var publishButton = $('.js-publish-button'),
saved,
enablePublish = function (deferred) {
deferred.always(function () {
publishButton.prop('disabled', false);
});
return deferred;
};
publishButton.prop('disabled', true);
_.each(this.model.blacklist, function (item) { _.each(this.model.blacklist, function (item) {
this.model.unset(item); this.model.unset(item);
}, this); }, this);
var saved = this.model.save(_.extend({ saved = this.model.save(_.extend({
title: $('#entry-title').val(), title: $('#entry-title').val(),
markdown: Ghost.currentView.getEditorValue() markdown: Ghost.currentView.getEditorValue()
}, data)); }, data));
@ -232,9 +243,10 @@
// TODO: Take this out if #2489 gets merged in Backbone. Or patch Backbone // TODO: Take this out if #2489 gets merged in Backbone. Or patch Backbone
// ourselves for more consistent promises. // ourselves for more consistent promises.
if (saved) { if (saved) {
return saved; return enablePublish(saved);
} }
return $.Deferred().reject();
return enablePublish($.Deferred().reject());
}, },
reportSaveSuccess: function (status, prevStatus) { reportSaveSuccess: function (status, prevStatus) {