Browse Source

表单增加 data-confirm 配置

邹景立 3 years ago
parent
commit
1f7f94431c
1 changed files with 8 additions and 4 deletions
  1. 8 4
      public/static/admin.js

+ 8 - 4
public/static/admin.js

@@ -492,10 +492,14 @@ $(function () {
         $('form[data-auto]').map(function (index, form) {
             if (this.dataset.listen === 'true') return true;
             $(this).attr('data-listen', 'true').vali(function (data) {
-                var call = form.dataset.callable || '_default_callable';
-                var type = form.method || 'POST', tips = form.dataset.tips || undefined;
-                var time = form.dataset.time || undefined, href = form.action || location.href;
-                $.form.load(href, data, type, window[call] || undefined, true, tips, time);
+                var type = form.method || 'POST', href = form.action || location.href;
+                var call = window[form.dataset.callable || '_default_callable'] || undefined;
+                var tips = form.dataset.tips || undefined, time = form.dataset.time || undefined;
+                (function (confirm, callable) {
+                    confirm ? $.msg.confirm(confirm, callable) : callable();
+                })(form.dataset.confirm, function () {
+                    $.form.load(href, data, type, call, true, tips, time);
+                });
             });
         });
     };