后台逻辑
编辑cms.views.py
@bp.route(‘/dbanner/‘,methods=[‘POST‘]) @login_required def dbanner(): banner_id = request.form.get(‘banner_id‘) if not banner_id: return xjson.json_param_error(message=‘请传入轮播图id!‘) banner = BannerModel.query.get(banner_id) if not banner: return xjson.json_param_error(message=‘没有这个轮播图!‘) db.session.delete(banner) db.session.commit() return xjson.json_success()
前台逻辑
编辑banner.js
$(function () { $(".delete-banner-btn").click(function (event) { var self = $(this); var tr = self.parent().parent(); var banner_id = tr.attr(‘data-id‘); xtalert.alertConfirm({ "msg":"您确定要删除这个轮播图吗?", ‘confirmCallback‘: function () { bbsajax.post({ ‘url‘: ‘/cms/dbanner/‘, ‘data‘:{ ‘banner_id‘: banner_id }, ‘success‘: function (data) { if(data[‘code‘] == 200){ window.location.reload(); }else{ xtalert.alertInfo(data[‘message‘]); } } }) } }); }); });
原文地址:https://www.cnblogs.com/sellsa/p/9563323.html
时间: 2024-10-29 13:39:37