add_group.html
2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<div class="modal fade" id="add_group" tabindex="-1" role="basic"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true"></button>
<h4 class="modal-title">新增分组</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" id="group_add_form"
action="/module" method="post">
<input type="hidden" name="groupType" value="1">
<input type="hidden" name="enable" value="1">
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
您的输入有误,请检查下面的输入项
</div>
<div class="form-body">
<div class="form-group">
<label class="col-md-3 control-label">分组名</label>
<div class="col-md-9">
<input type="text" class="form-control input-medium" name="name" > <span class="help-inline">
不要超过10个汉字长度 </span>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" id="addGroupModuleButton">提交数据</button>
</div>
</div>
</div>
</div>
<script>
$(function(){
$('#add_group').modal('show');
var form = $('#group_add_form');
var error = $('.alert-danger', form);
//提交
$('#addGroupModuleButton').on('click', function() {
form.submit();
});
//form validate
form.validate({
errorElement : 'span',
errorClass : 'help-block help-block-error',
focusInvalid : false,
rules : {
name : {
minlength : 2,
required : true,
maxlength : 10
}
},
invalidHandler : function(event, validator) {
error.show();
App.scrollTo(error, -200);
},
highlight : function(element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight : function(element) {
$(element).closest('.form-group').removeClass('has-error');
},
success : function(label) {
label.closest('.form-group').removeClass('has-error');
},
submitHandler : function(f) {
var params = form.serializeJSON();
error.hide();
$post('/module', params, function(res){
layer.msg('新增分组成功.');
refreshJsTree();
$('#add_group').modal('hide');
});
}
});
});
</script>