Feature request
Bind Events in Control Creation & Enable Code Chaining
Customer's remarks
I would like the ability to bind events to controls in the property list during creation. This would clean up my code by freeing me from creating a variable for every control, when the only purpose for the variable is assigning an event.
Secondly, when a method is called on an object, the return of the method should be the control so you can chain your code.
Sample
var win = Ti.UI.createWindow();
var lbl =Ti.UI.createLabel({
text: 'test'
});
lbl.addEventListener('click', function({ alert(this.text); });
win.add(lbl);
win.open()
Could become
Ti.UI.createWindow().add(Ti.UI.createLabel({
text: 'test',
eventClick: function(){ alert(this.text); }
}).open();
This can easily be done using plain JavaScript. Take a look at this solution and see if it's something you can work with. Feel free to modify it and customize it for your own use. https://gist.github.com/pec1985/3758713