adding delete action

This commit is contained in:
Ezequiel Bergamaschi 2014-02-01 01:42:54 -03:00 committed by Ezequiel Bergamaschi
parent a4ae253ae3
commit 4200d85cc0
2 changed files with 28 additions and 4 deletions

View File

@ -182,7 +182,6 @@ $(function () {
} }
}; };
//live method is deprecated?
$(document).on('click', '#foldersContainer li', function (event) { $(document).on('click', '#foldersContainer li', function (event) {
// Deselect previous option ... // Deselect previous option ...
$('#foldersContainer li').removeClass('active'); $('#foldersContainer li').removeClass('active');
@ -208,12 +207,37 @@ $(function () {
} }
); );
$(document).on('click', "#deleteLabelBtn", function() {
var me = $(this);
$("#delete-label-dialog-modal").dialogForm({
url: "c/restful/labels/" + me.attr('labelid'),
type: 'DELETE',
postUpdate: function() {
var dataTable = $('#mindmapListTable').dataTable();
//remove the selected tag...
$("#foldersContainer li.active").remove();
//find the second li... (all)
$("#foldersContainer li:nth-child(2)").addClass("active");
dataTable.fnReloadAjax("c/restful/maps/?q=all", callbackOnTableInit, true);
event.preventDefault();
}
})
});
$(document).ready(fetchLabels({ $(document).ready(fetchLabels({
postUpdate: function(data) { postUpdate: function(data) {
var labels = data.labels; var labels = data.labels;
for (var i = 0; i < labels.length; i++) { for (var i = 0; i < labels.length; i++) {
createLabelItem(labels[i]) createLabelItem(labels[i], null)
} }
} }
})) }))
}); });
function reloadTable() {
// Reload the table data ...
var dataTable = $('#mindmapListTable').dataTable();
dataTable.fnReloadAjax("c/restful/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true);
event.preventDefault();
}

View File

@ -115,8 +115,8 @@ jQuery.fn.dialogForm = function (options) {
type:options.type ? options.type : 'POST', type:options.type ? options.type : 'POST',
contentType:"application/json; charset=utf-8", contentType:"application/json; charset=utf-8",
success:function (data, textStatus, jqXHR) { success:function (data, textStatus, jqXHR) {
var resourceId = jqXHR.getResponseHeader("ResourceId");
if (options.redirect) { if (options.redirect) {
var resourceId = jqXHR.getResponseHeader("ResourceId");
var redirectUrl = options.redirect; var redirectUrl = options.redirect;
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId); redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
@ -125,7 +125,7 @@ jQuery.fn.dialogForm = function (options) {
window.open(baseUrl + redirectUrl, '_self'); window.open(baseUrl + redirectUrl, '_self');
} else if (options.postUpdate) { } else if (options.postUpdate) {
options.postUpdate(formData); options.postUpdate(formData, resourceId);
} }
dialogElem.modal('hide'); dialogElem.modal('hide');
}, },