From bc81179163642098ee27cf43aff25c4c68f3e12c Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 12 Apr 2012 22:25:40 +0200 Subject: Fix categories delete fallback when there is no app specific ajax categories delete function --- core/js/oc-vcategories.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'core/js') diff --git a/core/js/oc-vcategories.js b/core/js/oc-vcategories.js index e3b1abba08d..d5a9b0016de 100644 --- a/core/js/oc-vcategories.js +++ b/core/js/oc-vcategories.js @@ -53,25 +53,21 @@ OCCategories={ } }); }, + _processDeleteResult:function(jsondata, status, xhr){ + if(jsondata.status == 'success'){ + OCCategories._update(jsondata.data.categories); + } else { + OC.dialogs.alert(jsondata.data.message, 'Error'); + } + }, doDelete:function(){ var categories = $('#categorylist').find('input[type="checkbox"]').serialize(); categories += '&app=' + OCCategories.app; console.log('OCCategories.delete: ' + categories); - $.post(OC.filePath(OCCategories.app, 'ajax', 'categories/delete.php'),categories,function(jsondata, status, xhr){ - if (status == 'error' && xhr.status == 404) { - $.post(OC.filePath('core', 'ajax', 'vcategories/delete.php'),categories,function(jsondata, status, xhr){ - if(jsondata.status == 'success'){ - OCCategories._update(jsondata.data.categories); - } else { - OC.dialogs.alert(jsondata.data.message, 'Error'); - } - }); - return; - } - if(jsondata.status == 'success'){ - OCCategories._update(jsondata.data.categories); - } else { - OC.dialogs.alert(jsondata.data.message, 'Error'); + $.post(OC.filePath(OCCategories.app, 'ajax', 'categories/delete.php'), categories, OCCategories._processDeleteResult) + .error(function(xhr){ + if (xhr.status == 404) { + $.post(OC.filePath('core', 'ajax', 'vcategories/delete.php'), categories, OCCategories._processDeleteResult); } }); }, -- cgit v1.2.3