33 lines
1004 B
HTML
33 lines
1004 B
HTML
{{define "style"}}
|
|
{{end}}
|
|
|
|
{{define "content"}}
|
|
<h2>通用弹出表单示例</h2>
|
|
<!-- 触发按钮 -->
|
|
<button id="openFormButton" class="btn btn-primary">打开表单</button>
|
|
{{end}}
|
|
|
|
{{define "script"}}
|
|
<script src="/static/js/lib/modal.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
// 示例字段配置
|
|
let fields = [
|
|
{ label: '用户名:', name: 'username', type: 'text' },
|
|
{ label: '密码:', name: 'password', type: 'password' },
|
|
{ label: '确认密码:', name: 'password', type: 'password' }
|
|
]
|
|
|
|
// 初始化表单并显示
|
|
$('#openFormButton').on('click', function() {
|
|
let title = '用户注册'
|
|
let modal = new Modal(title, fields,function(data) {
|
|
console.log('表单提交数据:', data)
|
|
// 在此处处理表单提交,例如通过 AJAX 发送到服务器
|
|
})
|
|
modal.RenderModalForm()
|
|
})
|
|
})
|
|
</script>
|
|
{{end}}
|