Giải pháp chuyển đổi số trọn gói cho doanh nghiệp Việt
Tại thư mục public/assets/ecommerce/views_assets/js
Tạo file view-carcategories-list.js
Nội dung file
(function ($) {
$.view_carcategories_list = function (element, options) {
var defaults = {}
var plugin = this;
plugin.settings = {}
var $element = $(element),
element = element;
plugin.delete_row = function ($category) {
let category_id = $category.data('category_id');
$.ajax({
type: "POST",
dataType: "json",
url: `${root_url_api}/api_task/category.delete_category`,
data: {
category_id: category_id
},
beforeSend: function () {
// setting a timeout
//
},
error: function (xhr) { // if error occured
},
complete: function () {
},
success: function (response) {
if (response.result === "success") {
$.confirm({
title: 'Thông báo',
content: 'clear cache success',
type: 'green',
buttons: {
ok: {
text: "ok!",
btnClass: 'btn-primary',
keys: ['enter'],
action: function () {
$category.remove();
}
}
}
});
} else {
$.confirm({
title: 'Error',
content: 'Error process clear cache',
type: 'red'
});
}
}
});
}
plugin.init = function () {
plugin.settings = $.extend({}, defaults, options);
$element.find('.category-item .btn-delete-row').click(function (e) {
let $category = $(this).closest('.category-item');
$.confirm({
title: 'Confirm!',
content: 'Are you sure delete this item!',
buttons: {
confirm: function () {
plugin.delete_row($category);
},
cancel: function () {
}
}
});
});
};
plugin.init();
}
$.fn.view_carcategories_list = function (options) {
return this.each(function () {
if (undefined == $(this).data('view_carcategories_list')) {
var plugin = new $.view_carcategories_list(this, options);
$(this).data('view_carcategories_list', plugin);
}
});
}
})(jQuery);
Chưa có câu hỏi nào cho bài này.