Get delete page feature working

This commit is contained in:
Alvin Chow 2015-09-27 21:57:56 -07:00
parent 4ef08cc988
commit 4e4cdf6348
6 changed files with 43 additions and 5 deletions

View file

@ -58,10 +58,31 @@ $(function(){
});
$("#delete-page-btn").click(function() {
bootbox.alert("Not Done Yet! Sorry");
bootbox.confirm('Are you sure you want to delete this page?', function(result) {
if (result) {
deletePage();
}
});
});
});
var deletePage = function() {
var pageName = $page_name.val();
var path = Config['RELATIVE_PATH'] + '/' + pageName;
$.ajax({
type: 'DELETE',
url: path,
}).done(function(data) {
var msg = 'Deleted page: ' + pageName;
bootbox.alert(msg, function() {
location.href = '/';
});
}).fail(function(data, status, error) {
bootbox.alert('Error deleting page!');
});
};
var aced = new Aced({
editor: $('#entry-markdown-content').find('.editor').attr('id'),
renderer: function(md) { return MDR.convert(md) },