When processing custom events, the source of the event is not passing complete. This used to work in SDK 1.7.6.
1. Create a new mobile Project
2. PAste this:
var fundListSize,fundCheckboxArray=[],fundsToPlotCount,grey=false,lightBlue=false,clickEvent=false,fundsSitemanagerMsg=null;
var win = createHistoricalFundGraphFundsWindow();
win.orientationModes = [Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT];
win.open()
/*
* Function to display the available funds that can be selected to display on the graph
*/
function createHistoricalFundGraphFundsWindow() {
/* Declaring the variables*/
var iOSTopTitle, planText, navTitleText, menuTitle, winLeftNavButton, winRightNavButton, winBackButtonTitle, winBackButtonTitleImage, winTabBarHidden, subHeader, tableViewDS, genericTableView, win;
fundsSitemanagerMsg = ''//_response.historicalFundGraphFundMessage;
fundsToPlotCount = 3;
/* reset fundlistsize*/
fundListSize = 0;
tableViewDS = createHistoricalFundGraphFundsTableViewDS();
genericTableView = Titanium.UI.createTableView({
separatorColor:'#e7e7e7',
data : tableViewDS,
backgroundColor :'#e7e7e7'
});
genericTableView.top = 0;
genericTableView.backgroundColor = '#e7e7e7';
tableViewDS = null;
var menuWindow = Titanium.UI.createWindow({
barColor : '#929292',
backgroundColor : '#E7E7E7'
});
menuWindow.add(genericTableView);
return menuWindow;
};
/*
* Function to create the data source to be added to the tableview that displays the funds
*/
function createHistoricalFundGraphFundsTableViewDS() {
var responseLength=2;
var datasource=[];
var datasourceChecked=[];
var fundRow,boxChecked;
boxChecked=false;
fundCheckboxArray.push(createHFGCheckBox('','xyz',boxChecked));
fundCheckboxArray.push(createHFGCheckBox('','abc',boxChecked));
fundRow=createHFGRowLndScpe({
fFundName: 'xyz',
sSwitch: fundCheckboxArray[0]
});
var fundRow1=createHFGRowLndScpe({
fFundName: 'abc',
sSwitch: fundCheckboxArray[1]
});
datasource.push(fundRow);
datasource.push(fundRow1);
fundListSize = 2;
return datasource;
};
/*
* function to create checkbox ( a button masked as checkbox, not a switch ) for each row
*/
function createHFGCheckBox(_fundNum,_fundName,_checked) {
var checkbox = Ti.UI.createButton({
title:'',
right:'5%',
width:28,
height:28,
font: {
fontSize: 14,
fontWeight: 'bold'
},
value:_checked,
fundNum:_fundNum,
fundName:_fundName,
checkColor:'none'
});
/* attach on/off actions */
checkbox.on = function() {
this.value = true;
this.title='ON';
};
checkbox.off = function() {
this.value = false;
this.title='OFF';
};
/* fire action to check or uncheck based on _checked bool param */
if (_checked) {
checkbox.on();
} else {
checkbox.off();
}
checkbox.addEventListener('updateCheckBox', function(e) {
alert(e)
/* can always turn checkboxes off */
if(e.source.value == true)
{
checkbox.off();
}
else
{
checkbox.on();
}
});
return checkbox;
};
/*
* Function to create row for fund label
*/
function createHFGRowLndScpe(_fundBalData) {
if( typeof _fundBalData !== 'undefined' && _fundBalData !== null) {
var _fundName = _fundBalData.fFundName;
var row = Titanium.UI.createTableViewRow({
backgroundColor : '#FFFFFF',
selectedBackgroundColor : '#FFFFFF',
selectionStyle : 'NONE'
});
var checkBoxView = Ti.UI.createView({
right : 0,
height : 30,
width : '30%',
})
row.addEventListener('click', function(e) {
var id = e.index;
Ti.API.info('Row got click Source: '+e.source+' Row Index:'+e.index);
if( typeof id !== 'undefined' && id !== null) {
fundCheckboxArray[id].fireEvent('updateCheckBox');
}
});
var fundNameLabel = Titanium.UI.createLabel({
left : '5%',
width : '65%',
top : 15,
bottom : 15,
height : 'auto',
color : '#363636',
text : _fundName,
font : {
fontSize : 15,
fontFamily : 'Helvetica Neue',
fontWeight : 'bold'
},
});
row.add(fundNameLabel);
_fundName = null;
checkBoxView.add(_fundBalData.sSwitch);
row.add(checkBoxView);
return row;
}
};
3. Test in 1.7.6, working fine.
4. Now test in 2.1CI, it will fail.
The Alert attachment is the one coming from 1.7.6, working fine. The error one is from 2.1CI. Best, Mauro
Here's a simplified test case:
1. Run application. 2. Color should be blue initially. 3. Click the view. 4. Color should now be red. An alert should appear saying: "Message: Hello!". 5. No "Error" alerts should appear.
[PR #2159](https://github.com/appcelerator/titanium_mobile/pull/2159) submitted to address issue.
Hello Josh, do you think that will be in for today's or tomorrow's CI? Best, Mauro
Mauro, I would expect tomorrow, but depends on how quickly it can get reviewed. A possible workaround might be to just use the variable "checkbox" directly rather than using "e.source". Example:
Re-opening to deal with regression on Rhino runtime.
Tested with 2.0.2.v20120517141652 on LG Revolution 2.3.6 and Emulator 2.3.3
Reopening to update labels.
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4887