Crude post delete functionality, closes #42

This commit is contained in:
Ricardo Tomasi 2013-05-24 09:02:59 -03:00
parent 3adbbebc45
commit 1202b11a90
4 changed files with 22 additions and 7 deletions

View File

@ -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));

View File

@ -47,9 +47,9 @@
<a class="post-edit" href="#"><span class="hidden">Edit Post</span></a>
<a class="post-settings" href="#" data-toggle=".menu-drop-right"><span class="hidden">Post Settings</span></a>
<ul class="menu-drop-right">
<li><a href="#">URL</a></li>
<li><a href="#">Something</a></li>
<li><a href="#">Delete</a></li>
<li><a href="#" class="url">URL</a></li>
<li><a href="#" class="something">Something</a></li>
<li><a href="#" class="delete">Delete</a></li>
</ul>
</section>
</header>

View File

@ -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);
}
};

View File

@ -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);
};
/**