Problem Description
When an instance of Ti.UI.Switch exists in Ti.UI.TableViewRows with a className attribute set and enough rows are present in the table that they scroll all the way off the screen, some of the switches will fire 'change' events as they scroll on and off the screen.
Steps to reproduce
Create a new mobile project
paste this code into app.js
var window = Ti.UI.createWindow({
backgroundColor: '#FFF'
});
var tableView = Ti.UI.createTableView();
var data = [];
for (var i=0; i<50; i++) {
var row = Ti.UI.createTableViewRow({
height: 100,
className: 'myRow'
});
var mySwitch = Ti.UI.createSwitch({
value: i % 3 == 0,
number: i
});
mySwitch.addEventListener('change', function(e) {
alert("Switch " + e.source.number + " was changed!");
});
row.add(Ti.UI.createLabel({
text: i,
left: 20,
color: '#000'
}));
row.add(mySwitch);
data.push(row);
}
tableView.setData(data);
window.add(tableView);
window.open();
run this in device
just scroll down
I am able to reproduce this issue with the following environment; Pixel (7.1) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170623141152 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131