开发者

How do I cancel event bubbling in a YUI DataTable?

开发者 https://www.devze.com 2023-03-18 12:10 出处:网络
I am trying to create a YUI 2.8.1 DataTable with a checkbox column. When the user selects the row it should highlight, but not when the user checks the checkbox.

I am trying to create a YUI 2.8.1 DataTable with a checkbox column. When the user selects the row it should highlight, but not when the user checks the checkbox.

I'm trying to suppress the rowClickEvent by setting cancelBubble = true in the checkboxClickEvent, but the YUI library ignores this. How do I prevent the rowClickEvent from firing?

this.testDataTable.subscribe("checkboxClickEvent", function (oArgs)
{
    var elCheckbox = oArgs.target;
    var oRecord = this.get开发者_如何转开发Record(elCheckbox);
    oRecord.setData("check", elCheckbox.checked);
    oArgs.event.cancelBubble = true; //Event bubbles anyway
});


return false from the checkboxClickEvent


I've worked around the issue by setting a flag to suppress row click, but I'd still like to know how to cancel the bubble "properly."

suppressHighlight = false;

this.testDataTable.onEventRowClick = function (oArgs)
{
    ...

    if (!suppressHighlight)
    {
        ...
    }
    suppressHighlight = false;
};
this.testDataTable.subscribe("rowClickEvent", this.testDataTable.onEventRowClick);

this.testDataTable.subscribe("checkboxClickEvent", function (oArgs)
{
    var elCheckbox = oArgs.target;
    var oRecord = this.getRecord(elCheckbox);
    oRecord.setData("Check", elCheckbox.checked);

    suppressHighlight = true;
});
0

精彩评论

暂无评论...
验证码 换一张
取 消