【问题标题】:How to maintain scroll position of bootstrap table on reload?如何在重新加载时保持引导表的滚动位置?
【发布时间】:2020-03-21 14:53:51
【问题描述】:

我有一个如下所示的引导表。

    <div class="row">
    <table id="question-selection" class="table table-sm table-hover table-wrapper">
        <tbody>

            {% for placer in chapter_questions %}

            {% if placer == question %}

            <tr id="active-table" style="transform: rotate(0);">

            {% else %}

            <tr style="transform: rotate(0);">

            {% endif %}

                <th scope="row">

                    <a href="{% url 'question' placer.slug %}" class="stretched-link"></a></th>

                <td class="pr-3 pl-3 pt-2 pb-2">{{ placer|truncatewords:10 }}</td>
            </tr>

            {% endfor %}

        </tbody>
    </table>
</div>

我希望表格中的活动行位于框架中,因为我看不到当前单击的内容。另外,当我重新加载页面时,我希望它保持滚动位置。

【问题讨论】:

    标签: html ajax bootstrap-4 bootstrap-table


    【解决方案1】:

    我终于让它在我的代码中使用一点 jQuery。这里适合所有遇到同样问题的人。

       <script>
    
            var current_pos = $('#active-table').position().top;
    
            $(document).ready(function () {
                $("table").scrollTop(current_pos);
            });
    
        </script>
    

    【讨论】:

      猜你喜欢
      • 2014-11-18
      • 1970-01-01
      • 2017-02-23
      • 2012-10-16
      • 2015-02-20
      • 2012-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多