Giải pháp chuyển đổi số trọn gói cho doanh nghiệp Việt

Tạo view view-carcategories-list.js - Xây dựng giao diện backend của hệ thống quản lý admin.adayroi.online

Xây dựng giao diện backend của hệ thống quản lý admin.adayroi.online

← Toàn bộ tài liệu


Bước 8.3: Tạo view view-carcategories-list.js

Bài 14/33 Xem dạng sách

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

Sơ đồ quan hệ các bảng

Table Name: {{table.name}}
Num Name Type
{{field_index+1}}
{{field.name}} {{field.type}}

Hỏi đáp

Gửi với tên {{comment_full_name}}

Chưa có câu hỏi nào cho bài này.

Zalo 0936.006.058 Hotline 0936.006.058