diff --git a/core/admin/assets/js/blog.js b/core/admin/assets/js/blog.js index 84a2a199af..ff8d5b872f 100644 --- a/core/admin/assets/js/blog.js +++ b/core/admin/assets/js/blog.js @@ -22,6 +22,21 @@ } }); + $('.post-controls .delete').on('click', function (e) { + e.preventDefault(); + var postID = $('.content-list-content').find('li.active').data('id'); + $.ajax({ + method: 'DELETE', + url: '/api/v0.1/posts/' + postID, + success: function (res) { + window.location.reload(); + }, + error: function () { + window.alert('Delete failed.'); + } + }); + }); + }); }(jQuery)); \ No newline at end of file diff --git a/core/admin/views/blog.hbs b/core/admin/views/blog.hbs index 730984d3b8..5e114b5304 100644 --- a/core/admin/views/blog.hbs +++ b/core/admin/views/blog.hbs @@ -47,9 +47,9 @@ diff --git a/core/shared/api.js b/core/shared/api.js index db32e6f835..d106280824 100644 --- a/core/shared/api.js +++ b/core/shared/api.js @@ -43,8 +43,8 @@ }, // takes an identifier (id or slug?) // returns a json response with the id of the deleted post - destroy: function (id) { - return when.call(ghost.dataProvider().posts.destroy, id); + destroy: function (args) { + return when.call(ghost.dataProvider().posts.destroy, args.id); } }; diff --git a/core/shared/models/dataProvider.bookshelf.js b/core/shared/models/dataProvider.bookshelf.js index 5abc72d18e..f18cb0fcdd 100644 --- a/core/shared/models/dataProvider.bookshelf.js +++ b/core/shared/models/dataProvider.bookshelf.js @@ -81,8 +81,8 @@ DataProvider.prototype.posts.destroy = function (_identifier, callback) { models.Post.forge({id: _identifier}).destroy().then(function () { - callback(null); - }); + callback(null, 'ok'); + }, callback); }; /**