소스 검색

修复action confirm弹窗显示异常问题

jqh 5 년 전
부모
커밋
be1f2d8ffe
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 1
      src/Actions/Action.php
  2. 5 5
      src/Actions/HasActionHandler.php

+ 1 - 1
src/Actions/Action.php

@@ -215,7 +215,7 @@ HTML;
         }
 
         if ($confirm = $this->confirm()) {
-            $this->setHtmlAttribute('data-confirm', $confirm);
+            $this->setHtmlAttribute('data-confirm', json_encode((array) $confirm));
         }
 
         $this->addHandlerScript();

+ 5 - 5
src/Actions/HasActionHandler.php

@@ -78,7 +78,7 @@ trait HasActionHandler
 $('{$this->selector()}').off('{$this->event}').on('{$this->event}', function() {
     var data = $(this).data(),
         target = $(this);
-    if (target.attr('working') > 0) {
+    if (target.attr('loading') > 0) {
         return;
     }
     {$this->actionScript()}
@@ -98,14 +98,14 @@ JS;
 
         return <<<JS
 function request() {
-    target.attr('working', 1);
+    target.attr('loading', 1);
     Object.assign(data, {$parameters});
     {$this->buildActionPromise()}
     {$this->handleActionPromise()}
 }
 
 if (data['confirm']) {
-    Dcat.confirm(data['confirm'], request);
+     Dcat.confirm(data['confirm'][0], data['confirm'][1], request);
 } else {
     request()
 }
@@ -138,12 +138,12 @@ var process = new Promise(function (resolve,reject) {
         url: '{$this->handlerRoute()}',
         data: data,
         success: function (data) {
-            target.attr('working', 0);
+            target.attr('loading', 0);
             Dcat.NP.done();
             resolve([data, target]);
         },
         error:function(request){
-            target.attr('working', 0);
+            target.attr('loading', 0);
             Dcat.NP.done();
             reject([request, target]);
         }