24-----BBS論壇
阿新 • • 發佈:2018-11-26
board -i ext list title .post prevent priority href
BBS論壇(二十四)
24.1.編輯板塊
cms/js/banners.js
$(function () { $(‘.edit-board-btn‘).click(function () { var self = $(this); var tr = self.parent().parent(); var name = tr.attr(‘data-name‘); var board_id = tr.attr(‘data-id‘); zlalert.alertOneInput({‘title‘: ‘編輯板塊‘, ‘text‘: ‘請輸入版塊名稱‘, ‘placeholder‘: name, ‘confirmCallback‘: function (inputValue) { zlajax.post({ ‘url‘: ‘/cms/uboards/‘, ‘data‘: { ‘board_id‘: board_id,‘name‘: inputValue }, ‘success‘: function (data) { if (data[‘code‘] == 200) { window.location.reload(); } else { zlalert.alertInfo(data[‘message‘]) } } }); } }); }); });
24.2.刪除板塊
cms/js/banners.js
$(function () { $(‘.delete-board-btn‘).click(function (event) { event.preventDefault(); var self = $(this); var board_id = self.parent().parent().attr(‘data-id‘); zlalert.alertConfirm({ ‘title‘: ‘刪除版塊‘, ‘msg‘: ‘確認刪除該版塊嗎?‘, ‘confirmCallback‘: function () { zlajax.post({ ‘url‘: ‘/cms/dboards/‘, ‘data‘: { ‘board_id‘: board_id }, ‘success‘: function (data) { if (data[‘code‘] == 200) { window.location.reload(); } else { zlalert.alertInfo(data[‘message‘]); } } }); } }) }) });
24.3.首頁動態顯示板塊
(1)front/views.py
@bp.route(‘/‘) def index(): banners = BannerModel.query.order_by(BannerModel.priority.desc()).limit(4) boards = BoardModel.query.all() context = { ‘banners‘:banners, ‘boards‘:boards } return render_template(‘front/front_index.html‘,**context)
(2)front/index.py
<div class="sm-container"> <div style="margin-bottom: 10px;"> <button class="btn btn-warning btn-block">發布帖子</button> </div> <div class="list-group"> <a href="#" class="list-group-item active">所有板塊</a> {% for board in boards %} <a href="#" class="list-group-item">{{ board.name }}</a> {% endfor %} </div> </div>
- 24.1.編輯板塊
- 24.2.刪除板塊
- 24.3.首頁動態顯示板塊
24-----BBS論壇