Twitter Bootstrap下拉列表的事件处理程序? [英] Event handlers for Twitter Bootstrap dropdowns?

查看:76
本文介绍了Twitter Bootstrap下拉列表的事件处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Twitter Bootstrap下拉按钮

    <div class="btn-group">
      <button class="btn dropdown-toggle" data-toggle="dropdown">Action <span class="caret"></span></button>
      <ul class="dropdown-menu">
        <li><a href="#">Action</a></li>
        <li><a href="#">Another action</a></li>
        <li><a href="#">Something else here</a></li>
      </ul>
    </div><!-- /btn-group -->

当用户将按钮的值更改为另一个操作时,而不是简单地导航到,我实际上想以自定义方式处理动作。

When the user changes the value of the button to 'Another action', instead of simply navigating to #, I'd actually like to handle the action in a custom way.

但我看不到任何事件处理程序用于执行此操作的下拉插件

But I can't see any event handlers in the dropdown plugin for doing this.

是否可以使用Bootstrap下拉按钮来处理用户操作?我开始怀疑它们是否仅用于导航 - 这个例子给出了一系列动作令人困惑。

Is it actually possible to use Bootstrap dropdown buttons to handle user actions? I'm starting to wonder if they're only intended for navigation - it's confusing that the example gives a list of actions.

推荐答案

Twitter引导程序旨在提供基线功能,并且仅提供执行某些操作的基本javascript插件 在屏幕上 。任何其他内容或功能,您必须自己做。

Twitter bootstrap is meant to give a baseline functionality, and provides only basic javascript plugins that do something on screen. Any additional content or functionality, you'll have to do yourself.

<div class="btn-group">
  <button class="btn dropdown-toggle" data-toggle="dropdown">Action <span class="caret"></span></button>
  <ul class="dropdown-menu">
    <li><a href="#" id="action-1">Action</a></li>
    <li><a href="#" id="action-2">Another action</a></li>
    <li><a href="#" id="action-3">Something else here</a></li>
  </ul>
</div><!-- /btn-group -->

然后使用jQuery

and then with jQuery

jQuery("#action-1").click(function(e){
//do something
e.preventDefault();
});

这篇关于Twitter Bootstrap下拉列表的事件处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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