简体   繁体   English

具有Ajax加载内容的Bootstrap响应式选项卡

[英]Bootstrap Responsive Tabs with Ajax loaded content

I am having a lot of tabs in my website designed with Bootstrap which I tried to make responsive using https://github.com/flatlogic/bootstrap-tabcollapse (Demo here: http://tabcollapse.okendoken.com/example/example.html ) 我的网站上有很多使用Bootstrap设计的标签,我尝试使用https://github.com/flatlogic/bootstrap-tabcollapse使其具有响应性(此处的演示: http : //tabcollapse.okendoken.com/example/example .html

I was able to make the tabs responsive but the problem is I am loading content into the tabs using AJAX (like https://coderwall.com/p/1lnxba/load-bootstrap-tabs-dynamically ) and the problem is that the entire markup of the tab changes to panel when resized to small size and id of the element is also changed. 我能够使选项卡响应,但是问题是我正在使用AJAX将内容加载到选项卡中(例如https://coderwall.com/p/1lnxba/load-bootstrap-tabs-dynamically ),问题是整个当将标签的尺寸调整为较小尺寸时,选项卡的标记将更改为面板,并且元素的id也将更改。

So, how will I load the elements inside those tabs using ajax since markup is changed. 因此,由于标记已更改,我将如何使用Ajax在这些选项卡中加载元素。 I dont want to write separate code for loading for both cases. 我不想为这两种情况编写单独的代码来加载。

Or is there any other better alternative to this? 还是有其他更好的替代方法? Or some solution which does not change markup of tabs but still is responsive? 还是一些不更改标签标记但仍能响应的解决方案?

Thanks in advance. 提前致谢。

Try using Bootstrap's Containers to hold the AJAX-loaded content. 尝试使用Bootstrap的容器来容纳AJAX加载的内容。

I'm assuming your code is something like this (just the tab-pane bit), but you should update your question with at least a layout to get better responses. 我假设您的代码是这样的(只是制表位),但是您应该至少使用布局更新问题,以获得更好的响应。

<div class="tab-pane fade in active" id="home">
    <!-- ... Other Content ... -->
    <div id="ajaxContent" class="container">
        <!-- Where Tab 1 Content would go because it's active -->
    </div>
    <!-- ... Other Content ... -->
</div>

See Bootstrap's Components page for a full list of classes that you can use. 有关可以使用的类的完整列表,请参见Bootstrap的Components页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM