简体   繁体   English

Twitter Bootstrap模态滑块向下滑动并淡入,但在关闭时会立即关闭,而不会向上滑动淡出过渡

[英]Twitter Bootstrap modal slides down and fades in, but upon close, it immediately closes, it does not do a slide up fade out transition

The modal works fine, but when you try to close it, it doesn't do the same slide up fade out animation as the demo on the bootstrap javascript page. 该模式可以正常工作,但是当您尝试将其关闭时,它不会像引导javascript页面上的演示那样执行相同的向上滑动淡出动画。

I did some debugging and in my version, when it hits $this.element.trigger(e);, it immediately closes the popup. 我做了一些调试,在我的版本中,当它命中$ this.element.trigger(e);时,它立即关闭了弹出窗口。 However in bootstrap's demo version, it reaches $this.element.trigger(e), it has no effect on screen and reaches $.supportTransition, and once it hits hideWithTransition(), it slides up and fades out like its supposed to. 但是,在bootstrap的演示版中,它达到$ this.element.trigger(e),在屏幕上没有任何作用,达到$ .supportTransition,一旦击中hideWithTransition(),它就会像预期的那样向上滑动并逐渐消失。

Anybody have any idea whats going on? 有人知道发生了什么吗? Thank you for any help. 感谢您的任何帮助。

modal: 模式:

<div id="myModal" class="modal hide fade" style="display: none;" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
<div class="modal-header">
  <button type="button" class="close" data-target="myModal" data-dismiss="modal" aria-hidden="true">&times;</button>
  <h3 id="myModalLabel">Modal Heading</h3>
</div>
<div class="modal-body">
  <h4>Text in a modal</h4>
  <p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem.</p>

  <h4>Popover in a modal</h4>
  <p>This <a href="#" role="button" class="btn popover-test" title="A Title" data-content="And here's some amazing content. It's very engaging. right?">button</a> should trigger a popover on click.</p>

  <h4>Tooltips in a modal</h4>
  <p><a href="#" class="tooltip-test" title="Tooltip">This link</a> and <a href="#" class="tooltip-test" title="Tooltip">that link</a> should have tooltips on hover.</p>

  <hr>

  <h4>Overflowing text to show optional scrollbar</h4>
  <p>We set a fixed <code>max-height</code> on the <code>.modal-body</code>. Watch it overflow with all this extra lorem ipsum text we've included.</p>
  <p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
  <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
  <p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
  <p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
  <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
  <p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
</div>

<div class="modal-footer">
  <button class="btn" data-dismiss="modal">Close</button>
  <button class="btn btn-primary">Save changes</button>
</div>

</div>

anchor modal trigger: 锚模式触发器:

<a role="button" data-toggle="modal"  href="#myModal" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a>

I forgot to mention that I am using this with a magento site. 我忘了提到我在magento网站上使用它。 I'm using magento community edition 1.7.0.2. 我正在使用magento社区版1.7.0.2。 There must be a conflict somewhere, otherwise it should work. 某处一定有冲突,否则它应该起作用。 I'll try a jsfiddle. 我将尝试一个jsfiddle。

UPDATE! 更新!

Ok, I found the culprit. 好吧,我找到了罪魁祸首。 I removed the prototype script that I'm using with Jquery in noconflict mode. 我在noconflict模式下删除了与Jquery一起使用的原型脚本。 Once I removed prototype it worked fine. 一旦我删除了原型,它就可以正常工作。 Anyone have any idea why that would happen with prototype? 任何人都知道为什么原型会发生这种情况吗? I'm going to continue trying to find out. 我将继续尝试找出答案。 Thanks. 谢谢。

Ok, I found the problem after debugging. 好的,我在调试后发现了问题。 When I step through the hide method of the bootstrap modal plugin, it calls prototypes hide method: 当我逐步完成引导程序模式插件的hide方法时,它将调用原型hide方法:

Element.Methods = {
  hide: function(element) {
    element = $(element);
    element.style.display = 'none';
    return element;
},

The stack trace shows that in jQuery.event.trigger, there is a statement: 堆栈跟踪显示,在jQuery.event.trigger中,有一条语句:

elem[type]();

, and this calls prototypes version of "methodize()", and when it does the statement ,这会调用“ methodize()”的原型版本,并在执行该语句时

 __method.apply(), it calls prototypes hide function.

See this related stackoverflow question, which helped me solve my problem popover-hides-parent-element-if-used-with-prototype 看到这个相关的stackoverflow问题,它帮助我解决了问题popover-hide-parent-element-if-use-with-prototype

All I had to do was rename the $.Event('hide') to $.Event('something_else') 我要做的就是将$ .Event('hide')重命名为$ .Event('something_else')

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

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