bootstrap崩溃事件捕获

时间:2014-06-04 22:51:46

标签: javascript twitter-bootstrap

我正在尝试更改崩溃时的图标并面临事件触发问题

HTML

    <div id="collapse-menu" class="row">
        <div class=" panel">
            <a href="#collapse-Content" data-toggle="collapse" data-parent="#main-menu">
                <h3>A default header<span class="glyphicon glyphicon-plus pull-right"></span></h3></a>
        </div>
        <div id="collapse-Content" class="collapse">
            Blah Blah! Some Content
        </div>
    </div

JS处理事件

$('.row').on('shown.bs.collapse', function(){
    $(this).find(".glyphicon-plus").removeClass("glyphicon-plus").addClass("glyphicon-minus");
});
$('.row').on('hidden.bs.collapse', function(){
    $(this).find(".glyphicon-minus").removeClass("glyphicon-minus").addClass("glyphicon-plus");
});

完成折叠后不会捕获此事件。我猜它被解雇了,因为.collapse被删除,类被更改为.in(默认的预期行为)。

这是捕获的正确事件吗?是不是在.row?

上触发的事件

1 个答案:

答案 0 :(得分:0)

当您尝试将事件附加到元素时,HTML有时不会完全呈现,因此您可以在setTimeout函数中添加代码。

private void AddButton_Click(object sender, EventArgs e)
{
    if (allUrlsDGV.CurrentRow == null)
        return;
    var drv = (DataRowView)allUrlsDGV.CurrentRow.DataBoundItem;
    drv.Row["Favorite"] = true;
    drv.Row.EndEdit();
}

private void RemoveButton_Click(object sender, EventArgs e)
{
    if (favoriteUrlsDGV.CurrentRow == null)
        return;
    var drv = (DataRowView)favoriteUrlsDGV.CurrentRow.DataBoundItem;
    drv.Row["Favorite"] = false;
    drv.Row.EndEdit();
}
相关问题