javascript - Bootstrap 表 : is it possible to call the function which sorts rows by column from code (without clicking the header)

标签 javascript jquery twitter-bootstrap

http://jsfiddle.net/e3nk137y/4537/

<table data-toggle="table"
    >
    <thead>
        <tr>
            <th data-field="fruit" data-sortable="true">Item</th>
            <th data-field="date"  data-sortable="true">Date</th>
            <th data-field="type"  data-sortable="true">Type</th>
        </tr>
    </thead>
    <tbody>
        <tr><td>Pear  </td><td data-month="1">January</td> <td>Fruit</td></tr>
        <tr><td>Carrot</td><td data-month="3">March</td>   <td>Vegetable</td></tr>
        <tr><td>Apple </td><td data-month="2">February</td><td>Fruit</td></tr>
    </tbody>
</table>

在此 fiddle 中是一个表格的示例。单击标题时,表格将按属于该标题的列进行排序。

我的问题是,是否可以通过其他方式(从其他函数)触发该函数。更一般地说:我可以显式调用从各种 Bootstrap 小部件中作为回调调用的函数吗?

最佳答案

您可以通过编程方式单击标题。这样可以达到你想要的效果吗?

$("th[data-field='fruit'] .sortable").click();

Fiddle

关于javascript - Bootstrap 表 : is it possible to call the function which sorts rows by column from code (without clicking the header),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35164654/

相关文章:

javascript - 为什么在使用事件冒泡时不调用无效事件的事件监听器?

javascript - 混合模式 :multiply in Internet Explorer

javascript - Bootstrap 3导航栏静态顶部在滚动动画时更改为固定顶部

jquery - 可折叠菜单对于移动横向来说太长

css - Twitter Bootstrap - 在行之间添加顶部空间

javascript - Canvas 旋转 - 固定背景,移动前景

javascript - FB 分享按钮在页面加载时消失

java - 多个复选框选中值

javascript - 如果 jquery 尚未加载,则加载 jquery;如果没有可用连接,则使用本地版本

javascript - jQuery 事件处理程序不会在单击时激活