Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1353] Setting cancelBubble TRUE doesn't work in TableView

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-08-03T15:27:55.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsbubbleparent, tableview
ReporterFokke Zandbergen
AssigneeShuo Liang
Created2014-07-21T04:28:13.000+0000
Updated2016-03-08T07:37:46.000+0000

Description

As the following example shows you will still get 2 alerts if you click on the button, even though the button sets cancelBubble = true, which should prevent the event from bubbling to the row and table.
var win = Ti.UI.createWindow({
  backgroundColor: 'white'
});

var row = Ti.UI.createTableViewRow();
var btn = Ti.UI.createButton({title:'click me'});

btn.addEventListener('click', function(e) {
  e.cancelBubble = true;
  alert('hi from row');
});

row.add(btn);

var table = Ti.UI.createTableView({
  top: 20,
  data: [row]
});

table.addEventListener('click', function(e) {
  alert('hi from table');
});

win.add(table);
win.open();

Comments

  1. Shuo Liang 2014-08-01

    Hi, You'd better change line 9 to
       btn.bubbleParent = false;
       
    as the e stands for the event for callback function, not the component. Regards, Shuo
  2. Fokke Zandbergen 2014-08-01

    Corrected that, sorry ;)
  3. Shuo Liang 2014-08-01

    Tried your new test case, It works well on iOS simulator 7 for both SDK 3.3.0 and 3.2.3. Clicking button only trigger one alert. What kind of device did you use to reproduce this problem.
  4. Fokke Zandbergen 2014-08-02

    I'm limited in what I can do here from the beach in France ;) I think it is safe to assume I made the same error in the test case as I did in the ticket and the ticket can be closed.

JSON Source