Browse Source

修复存在多个expand情况下异步加载功能异常问题

jqh 4 years ago
parent
commit
edde79339c
1 changed files with 5 additions and 5 deletions
  1. 5 5
      src/Grid/Displayers/Expand.php

+ 5 - 5
src/Grid/Displayers/Expand.php

@@ -54,14 +54,14 @@ class Expand extends AbstractDisplayer
             $this->button = $callbackOrButton;
         }
 
-        $this->addScript($remoteUrl);
+        $this->addScript();
 
         $key = $this->getDataKey();
 
         $button = is_null($this->button) ? $this->value : $this->button;
 
         return <<<EOT
-<span class="grid-expand" data-inserted="0" data-id="{$this->getKey()}" data-key="{$key}" data-toggle="collapse" data-target="#grid-collapse-{$key}">
+<span class="grid-expand" data-url="$remoteUrl" data-inserted="0" data-id="{$this->getKey()}" data-key="{$key}" data-toggle="collapse" data-target="#grid-collapse-{$key}">
    <a href="javascript:void(0)"><i class="feather icon-chevrons-right"></i>  $button</a>
 </span>
 <template class="grid-expand-{$key}">
@@ -82,11 +82,11 @@ EOT;
         return $this->grid->getName().$key.'-'.static::$counter;
     }
 
-    protected function addScript(?string $remoteUrl)
+    protected function addScript()
     {
-        $script = <<<JS
+        $script = <<<'JS'
 $('.grid-expand').off('click').on('click', function () {
-    var _th = $(this), url = "{$remoteUrl}";
+    var _th = $(this), url = _th.data('url');
     
     if ($(this).data('inserted') == '0') {