我想在用户提交表单后添加成功通知。
我已经查看了 Pnotify js 库 - https://sciactive.com/pnotify/,它看起来不错。但不知道如何在我的 CRUD 项目中使用。我正在使用 Spring Boot 和 Thymeleaf 作为前端。
我检查了文档:
<button class="btn btn-default source" onclick="new PNotify({
title: 'Regular Success',
text: 'That thing that you were trying to do worked!',
type: 'success',
styling: 'bootstrap3'
});">Success</button>
这是我的表格:
<form action="#" th:action="@{/contractors-save}"
th:object="${contractor}"
method="post" class="form-horizontal form-label-left">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Name</label>
<div class="col-md-5 col-sm-5 col-xs-12">
<input type="text" th:field="*{name}" class="form-control"
placeholder="name"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Description</label>
<div class="col-md-5 col-sm-5 col-xs-12">
<input type="text" th:field="*{description}"
class="form-control"
placeholder="description"/>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">
Close
</button>
<input type="submit" value="Save" class="btn btn-success">
</div>
通知显示在点击操作上,在我的情况下,我需要在表单提交后显示。你能建议和分享你的专业知识吗?也许还有其他选择。