实现写短评功能
imooc-reader 项目:
webapp\WEB-INF\ftl\
detail.ftl 图书详情页面
<!-- Modal 写短评的对话框 -->
<div class="modal fade" id="dlgEvaluation" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body">
<h6>为"${book.bookName}"写短评</h6>
<form id="frmEvaluation">
<div class="input-group mt-2 ">
<span id="score"></span>
</div>
<div class="input-group mt-2 ">
<input type="text" id="content" name="content" class="form-control p-4" placeholder="这里输入短评">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" id="btnSubmit" class="btn btn-primary">提交</button>
</div>
</div>
</div>
</div>
<#if loginMember ??>
//为"阅读状态"按钮绑定单击事件
$("*[data-read-state]").click(function(){
//获取被点击按钮的"data-read-state"属性值
var readState = $(this).data("read-state");
//发送post请求
$.post("/update_read_state", {
//请求参数
memberId: ${ loginMember.memberId},
bookId: ${ book.bookId},
readState: readState
}, function(json){
if(json.code == 0){ //服务端响应成功
//先移除高亮样式
$("*[data-read-state]").removeClass("highlight");
//当前被点击的元素添加高亮样式
// $(this).addClass("highlight");
$("*[data-read-state='" + readState + "']").addClass("highlight");
}
}, "json")
});
//为"写短评"按钮绑定单击事件, 弹出写短评对话框
$("#btnEvaluation").click(function(){