简体   繁体   English

当我单击导航栏中的按钮或其他按钮时,它会将我重定向到一个名为 undefined 的页面,但我想要做的是打开一个引导模式

[英]When I click a button in navbar or other button it redirects me to a page called undefined but what I want to do is open a bootstrap modal

When I click a button in navbar or other button it redirects me to a page called undefined but what I want to do is to open a bootstrap modal当我单击导航栏中的按钮或其他按钮时,它会将我重定向到一个名为undefined的页面,但我想要做的是打开一个引导模式

Explaining a little bit more I created a button on the page and when I put the <a> element inside the button it redirects to undefined page and I don't even have a href reference in there.再解释一下,我在页面上创建了一个按钮,当我将<a>元素放在按钮内时,它会重定向到未定义的页面,我什至在那里没有href引用。

<!--button-->
<button class="au-btn au-btn-icon au-btn--blue">
    <a data-toggle="modal" data-target="#uploadModal"><i class="zmdi zmdi-plus"></i>Adicionar Item</a>
</button>

<!--Modal-->
<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog" aria-labelledby="myMediulModalLabel">
    <div class="modal-dialog modal-md">
        <div style="color:white;background-color:#008CBA" class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h2 style="color:white" class="modal-title" id="myModalLabel">Upload Items</h2>
            </div>
            <div class="modal-body">
                <form enctype="multipart/form-data" method="post" action="additems.php">
                <fieldset>
                    <p>Name of Item:</p>
                    <div class="form-group">
                    <input class="form-control" placeholder="Name of Item" name="item_name" type="text" required>
                    </div>
                    <p>Price:</p>
                    <div class="form-group">
                    <input id="priceinput" class="form-control" placeholder="Price" name="item_price" type="text" required>
                    </div>
                    <p>Choose Image:</p>
                    <div class="form-group">
                    <input class="form-control"  type="file" name="item_image" accept="image/*" required/>
                    </div>
                </fieldset>
            </div>
            <div class="modal-footer">
                <button class="btn btn-success btn-md" name="item_save">Save</button>
                <button type="button" class="btn btn-danger btn-md" data-dismiss="modal">Cancel</button>
            </form>
            </div>
        </div>
    </div>
</div>

Why do you need anchor inside button .为什么你需要在 button 内锚定。 This is the reason its not working :-这就是它不起作用的原因:-

simply replace简单地替换

<button class="au-btn au-btn-icon au-btn--blue">
   <a data-toggle="modal" data-target="#uploadModal"><i class="zmdi zmdi-plus"></i>Adicionar Item</a></button>

with

<button class="au-btn au-btn-icon au-btn--blue" data-toggle="modal" data-target="#uploadModal">
  <i class="zmdi zmdi-plus"></i>Adicionar Item</button>

暂无
暂无

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

相关问题 我想在我的表格上添加编辑按钮并在单击演示模式按钮时打开 model 上的表单? - I want to add edit button on my table and open the form on model when click demo modal button? 为什么单击按钮时我的 Fewest Clicks 模态打开,但其他模态都没有打开? - Why does my Fewest Clicks modal open when I click the button but none of my other ones open? 我想当我点击模态上的单选按钮(objectart)时,它应该在另一个 div(objecttype)中更改模态上的其他 div 数据(获取数据库) - i want when i click on radio button (objectart) on modal then it should change other div data (fetch database) on modal in another div(objecttype) 单击删除按钮时如何打开模式? - How can I open the modal when I click the delete button? 我开发了一个api,我希望它重定向到其他php页面,并在我单击api文件中的按钮时弹出模式 - I developed a api and i want it to redirect to other php page and pop up the modal as i click the button in api file 当我单击注销按钮时,会打开确认警报。 当我取消时,它将重定向登录页面,但我想重定向当前页面。 我该怎么做? - When i click in logout button open a confirm alert. When i cancel it will redirect login page but i want to redirect current page. How i can do it? 如果我想在chrome开发工具上运行代码段时单击新页面上的按钮,该怎么办 - What should I do if I want to click button on the new page while running snippet on chrome dev tools 单击按钮时,如何使导航栏滚动页面? - How do I make a navbar scroll the page when clicked on a button? 单击按钮时打开模态 - Open modal when click on button 如何使用Twitter Bootstrap按钮点击导航到另一个页面? - How do I navigate to another page on button click with Twitter Bootstrap?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM