Bootstrap 3模式重定向页面打开

泰·贝利

我发生了一个非常奇怪的错误,我似乎无法弄清楚为什么。自从Bootstrap发行以来,我就一直在使用它,并且对它的工作方式非常熟悉。我已经设置了一个带有按钮的表单,这些按钮触发了位于文档底部的模式。当您单击触发模式的按钮时,它将打开模式,但刷新页面,将表单元素/值附加到URL,就好像它是使用GET方法提交表单一样刷新页面后,将不再打开模式,并且URL在查询中具有所有表单值。我一生无法弄清为什么会这样。应打开模式,并且页面应保持不受影响(模式打开除外)

以下是表单元素和模式按钮的HTML:

<div class='form-group'>
    <label class='control-label' for='store-name'>
        Store Name:
    </label>
    <div class='controls'>
        <input type='text' class='form-control' id='store-name' name='store-name'>
        <button class='btn btn-default' data-toggle='modal' data-target="#storeName">Lookup</button>
    </div>
</div>  

这是模式本身的HTML:

<!-- Store Name Modal -->
<div class="modal fade" id="storeName" tabindex="-1" role="dialog" aria-labelledby="storeName" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Stores</h4>
            </div>
            <div class="modal-body">
                <!-- Modal Content -->  
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save</button>
            </div>
        </div>
    </div>
</div>

包括所有脚本/样式,因为该模式实际上确实是打开的,当它打开时它只会重定向页面。有没有人遇到过这样的错误或有什么可能的原因?

蒂姆·威瑟斯

如果您<button>在表单内部,则HTML会将其解释为提交按钮。您的页面正在重新加载,因为该按钮实际上是每次单击都提交表单。

解决此问题的第一个选择是创建一个捕获事件并阻止其提交的函数。如果发件人内部有多个按钮,这可能会令人头疼。

从Bootstrap角度看,最简单的方法是将更<button class='btn'>改为<a class='btn'>引导程序以相同的方式设置样式,因此您可以互换使用它们。这样做的好处是,当您单击锚标记时,它不会提交您的表单。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

单击重定向到其他页面的“提交”按钮时,如何打开Bootstrap模式?

来自分类Dev

带有Bootstrap的AngularJS:单击模式时抑制重定向

来自分类Dev

Bootstrap v3-打开模式窗口会强制页面向上滚动到顶部

来自分类Dev

React-Bootstrap 模式始终在页面上打开/可见

来自分类Dev

Bootstrap模式冻结页面

来自分类Dev

Bootstrap:按顺序打开模式

来自分类Dev

确定哪个按钮打开了Bootstrap 3模式

来自分类Dev

jQuery打开远程URL的Bootstrap v3模式

来自分类Dev

Bootstrap 3模式更改

来自分类Dev

Bootstrap 3模式更改

来自分类Dev

使用React-Router关闭Bootstrap模式后进行重定向

来自分类Dev

如何在使用 Angular 6 重定向路由器链接后关闭 Bootstrap 模式

来自分类Dev

如何在关闭Bootstrap 3模式时重新加载页面

来自分类Dev

使用bootstrap angular js按钮而不是url.action重定向到页面

来自分类Dev

Bootstrap模式会在页面加载时自动打开,但是如果提交表单则如何禁用

来自分类Dev

无法打开页面进行多次重定向

来自分类Dev

无法打开页面进行多次重定向

来自分类Dev

隐藏Bootstrap 3 Modal和AngularJS重定向($ location.path)

来自分类Dev

Bootstrap 3子模式?

来自分类Dev

Bootstrap 3模式布局问题

来自分类Dev

在Bootstrap中打开模式放大图片

来自分类Dev

通过单击JQuery DataTable打开Bootstrap模式

来自分类Dev

在Griddle customComponent上打开Bootstrap模式

来自分类Dev

链接不会打开 Bootstrap 模式

来自分类Dev

Bootstrap Modal在新页面上打开

来自分类Dev

我想使用bootstrap react table2中的获取api id onclick按钮重定向页面

来自分类Dev

Bootstrap模式弹出窗口显示页面内容

来自分类Dev

在页面加载时显示此 Bootstrap 模式

来自分类Dev

在移动浏览器中打开Bootstrap 3模式时,如何防止后台滚动?

Related 相关文章

  1. 1

    单击重定向到其他页面的“提交”按钮时,如何打开Bootstrap模式?

  2. 2

    带有Bootstrap的AngularJS:单击模式时抑制重定向

  3. 3

    Bootstrap v3-打开模式窗口会强制页面向上滚动到顶部

  4. 4

    React-Bootstrap 模式始终在页面上打开/可见

  5. 5

    Bootstrap模式冻结页面

  6. 6

    Bootstrap:按顺序打开模式

  7. 7

    确定哪个按钮打开了Bootstrap 3模式

  8. 8

    jQuery打开远程URL的Bootstrap v3模式

  9. 9

    Bootstrap 3模式更改

  10. 10

    Bootstrap 3模式更改

  11. 11

    使用React-Router关闭Bootstrap模式后进行重定向

  12. 12

    如何在使用 Angular 6 重定向路由器链接后关闭 Bootstrap 模式

  13. 13

    如何在关闭Bootstrap 3模式时重新加载页面

  14. 14

    使用bootstrap angular js按钮而不是url.action重定向到页面

  15. 15

    Bootstrap模式会在页面加载时自动打开,但是如果提交表单则如何禁用

  16. 16

    无法打开页面进行多次重定向

  17. 17

    无法打开页面进行多次重定向

  18. 18

    隐藏Bootstrap 3 Modal和AngularJS重定向($ location.path)

  19. 19

    Bootstrap 3子模式?

  20. 20

    Bootstrap 3模式布局问题

  21. 21

    在Bootstrap中打开模式放大图片

  22. 22

    通过单击JQuery DataTable打开Bootstrap模式

  23. 23

    在Griddle customComponent上打开Bootstrap模式

  24. 24

    链接不会打开 Bootstrap 模式

  25. 25

    Bootstrap Modal在新页面上打开

  26. 26

    我想使用bootstrap react table2中的获取api id onclick按钮重定向页面

  27. 27

    Bootstrap模式弹出窗口显示页面内容

  28. 28

    在页面加载时显示此 Bootstrap 模式

  29. 29

    在移动浏览器中打开Bootstrap 3模式时,如何防止后台滚动?

热门标签

归档