简体   繁体   English

弹出式视窗内的轮播-引导程序

[英]Carousel inside popover - bootstrap

Using both Bootstrap components carousel and popover, I have encountered some conflict. 使用Bootstrap组件轮播和弹出窗口时,我遇到了一些冲突。 I need to utilize the carousel inside the popover, however they don't play nice together. 我需要利用弹窗内部的旋转木马,但是它们在一起玩起来并不好。 Is there a reason for this? 是否有一个原因?

Essentially the concept is pretty simple, if you want to login, the form is inside the popover and if you want to register, utilise the carousel inside the popover and slide to register form. 从本质上讲,该概念非常简单,如果要登录,则表单位于弹出框内,如果要注册,请利用弹出框内的轮播并滑动以注册表单。

Any Ideas? 有任何想法吗?

Bootply : Bootply

HTML: HTML:

<div class="login-popover hide">
  <div class="row">
    <div class="col-md-12">
      <div id="login-register" class="carousel slide" data-ride="carousel" data-interval="false">
        <div class="carousel-inner"><!-- Wrapper for slides -->
          <div class="item active"> <!-- Active is always 1st image-->
              Login Content
          </div>           
          <div class="item">
              Register Content
          </div>        
        </div>
          <!-- Controls for carousel-->
          <a class="left carousel-control" href="#login-register" data-slide="prev">
            <span class="glyphicon glyphicon-circle-arrow-left"></span>
          </a>
          <a class="right carousel-control" href="#login-register" data-slide="next">
            <span class="glyphicon glyphicon-circle-arrow-right"></span>
          </a>
      </div>
    </div>
  </div>
</div>

Javascript: 使用Javascript:

$('.login-pop').popover({
 placement: 'bottom',
  container: '.popover-login',
  trigger: 'click',
  animation: false,
  template: '<div class="popover login" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>',
  html: true,
  content: function () {
      return $(this).next('.login-popover').html();
  }
}); 

It is possible to put bootstrap carousel inside tooltip or popover. 可以将引导传送带放入工具提示或弹出框内。 Take a look at some examples: http://codepen.io/_danko/pen/wavmjG 看一些示例: http : //codepen.io/_danko/pen/wavmjG

Reason why it does not work in your case is because it (carousel) is not initialized. 在您的情况下不起作用的原因是因为它(轮播)未初始化。 You can initialize it with something like this: 您可以使用以下方式对其进行初始化:

$('.login-pop').on('shown.bs.popover', function () {
  // initialize carousel…
  $('.carousel-inner').carousel();
});

在进一步阅读Bootstrap弹出窗口后,将创建动态内容,因此这是不可能的。

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

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