Twitter的引导下拉菜单禁用点击按钮的原始功能 [英] Twitter bootstrap dropdown menu disables button's original function on click

查看:202
本文介绍了Twitter的引导下拉菜单禁用点击按钮的原始功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我刚开始使用引导程序的下拉菜单。这是非常方便的,但我有一个问题。

So I've just started using bootstrap's dropdown menu. It's very convenient, but I am having an issue.

为了在下拉菜单中的工作,似乎添加HTML属性数据切换时触发下拉列表(.dropdown-切换)元素的原始功能是完全禁用=下拉

In order for the dropdown menu to work, it seems that the original function of the element that triggers the dropdown (.dropdown-toggle) is completely disabled when adding the html attribute data-toggle="dropdown".

这是有道理的,因为你真的不想要一个下拉菜单切换是做其他神奇的东西(尤其是重定向到一个新的页面或锚当你试图访问菜单)。

This makes sense, because you don't really want a dropdown toggle to be doing other magical things (especially redirecting to a new page or anchor when you're trying to access a menu).

不过,我有一个提交按钮,通过AJAX保存的东西,当你点击它。我想在保存完成后,在下拉菜单中走出来。 我如何可以切换两个下拉菜单中的的执行一个Ajax请求按钮被点击时?

However, I have a submit button that saves something through ajax when you click it. I want the dropdown menu to come out after the save is performed. How can I toggle both the dropdown menu and perform an ajax request when the button is clicked?

还是在一个更模糊的感觉,我怎么切换,而preserving按键的原始功能的下拉菜单

Or in an even vaguer sense, how do I toggle the dropdown menu while preserving a button's original function?

也许,微博引导下拉菜单是不理想的功能呢?或者有没有修改这个?

Perhaps the twitter bootstrap dropdown menu is not the ideal function for this? Or are there modifications for this?

推荐答案

这是为我工作的Chrome浏览器。捕获按钮的点击事件,然后做你想做的。停止的情况下,如果有错误或一些与 stopPropagation() preventDefault()小提琴

This is working for me in Chrome. Capture the click event of the button and then do whatever you want. Stop the event if there is an error or something with stopPropagation() and preventDefault(). Fiddle

$("#buttonId").click(function(event) {
    if ("saved" == "saved") {
        null
    }
    else {
        event.stopPropagation();
        event.preventDefault();
    }
});​

这篇关于Twitter的引导下拉菜单禁用点击按钮的原始功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆