【问题标题】:Spotfire Accordion Text Area - cannot reopen panels after collapsingSpotfire Accordion 文本区域 - 折叠后无法重新打开面板
【发布时间】:2020-02-06 19:23:13
【问题描述】:

我正在使用 Spotfire 中的文本区域为我的过滤器制作手风琴,以便腾出空间。我下面的代码将切换以打开和关闭面板,并且一次多个。但是,我只能打开和关闭每个面板一次,然后它不允许我再次打开面板,直到我编辑 html 并保存它。

另外,我试图在面板打开时显示一个减号 (-) 并在再次关闭时返回一个加号。

<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>
    .accordion {
      background-color: #eee;
      color: #444;
      cursor: pointer;
      padding: 18px;
      width: 100%;
      border: none;
      text-align: left;
      outline: none;
      font-size: 15px;
      transition: 0.4s;
    }
    
    .active,
    .accordion:hover {
      background-color: #ccc;
    }
    
    .accordion:after {
      content: '\002B';
      color: #777;
      font-weight: bold;
      float: right;
      margin-left: 5px;
    }
    
    .active:after {
      content: "\2796";
    }
    
    .panel {
      padding: 0 18px;
      background-color: white;
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.2s ease-out;
    }
  </style>
</head>

<body>

  <button class="accordion" style="font-size:medium" ;><b>Department Roles</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="dca19548a0154f4582d1cc8c033f3ea6" />
    </p>
  </div>

  <button class="accordion" style="font-size:medium" ;><b>Studies with Critical Activities</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="228b526015ad4266946b65cad0a5d2dd" />
    </p>
  </div>

  <button class="accordion" style="font-size:medium" ;><b>Study Status</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="7a331814482e46bfb455f1cb06cdd569" />
    </p>
  </div>

  <button class="accordion" style="font-size:medium" ;><b>Site</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="dec00d7ee27244dc8f803190d2684b94" />
    </p>
  </div>

  <button class="accordion" style="font-size:medium" ;><b>Outsourced</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="44a7a79c5d1a497cb120ffe40b2a91cc" />
    </p>
  </div>

  <button class="accordion" style="font-size:medium" ;><b>Planned Start</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="39f882ba6a8f47a4b4257eff761d93e3" />
    </p>
  </div>

  <button class="accordion" style="font-size:medium" ;><b>Actual Start</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="f4fce188fc424d5cabc040b8eac977dd" />
    </p>
  </div>

  <button class="accordion" style="font-size:medium" ;><b>Study Path</b></button>
  <div class="panel">
    <p>
      <SpotfireControl id="c294b790054a4011aadaa89ee7ca36f1" />
    </p>
  </div>

  <script>
    var acc = document.getElementsByClassName("accordion");
    var i;
    for (i = 0; i < acc.length; i++) {
      acc[i].addEventListener("click", function() {
        this.classList.toggle("active");
        var panel = this.nextElementSibling;
        if (panel.style.maxHeight) {
          panel.style.maxHeight = null;
        } else {
          panel.style.maxHeight = panel.scrollHeight + "px";
        }
      });
    }
  </script>

</body>

</html>

【问题讨论】:

  • sn-p 有效,请问有什么问题?
  • 它在 Spotfire 之外工作,但在 Spotfire 中,一旦我关闭面板,我就无法重新打开面板,并且打开面板时 + 不会变为 -。我想知道 Spotfire 中的什么会导致这种情况。
  • 您可能需要强制刷新文本区域。如果您使用工具 > 开发 > 重新加载浏览器,一切正常吗?
  • 是的,我重新加载浏览器后它确实可以正常工作。我尝试过使用元标记来刷新。但这会使我的整个 Spotfire 应用程序每次(5 秒)都出现故障,并且不会使打开的面板保持打开状态。有没有办法解决这个问题?

标签: javascript html css accordion spotfire


【解决方案1】:

您可能希望将 JavaScript 添加到文本区域的 Js 部分。

此外,如果打开了 html 卫生,那么标签也将不起作用,并且必须使用文本区域中的 Js 进行附加。

https://datashoptalk.com/unscrambling-spotfire-text-area/

【讨论】:

    猜你喜欢
    • 2021-01-20
    • 2013-08-04
    • 2017-10-17
    • 2015-01-13
    • 2010-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-12
    相关资源
    最近更新 更多