Modal Picker
Hi all. I thought I'd share some code with you:
http://pastie.org/1333848
It's adapted from some code from another post, which I can't find. Sorry to the original author for not linking back to it.
Basically I wrapped up everything you need for a modal picker, like you often see in iPhone apps. Once you include the code, just do something like this:
picker_initialized = false;
my_button.addEventListener('click', function(e) {
if (!picker_initialized) {
modalPicker.init();
picker_initialized = true;
}
data = [...some data...];
modalPicker.show({
data: data,
on_select: function(e) {
var title = modalPicker.picker.getSelectedRow(0).title;
... do something ...
modalPicker.hide();
}
});
});
…hope that helps someone.
2 Answers
-
I think is adapted from my post here http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/ :)
-
Has anyone gotten this code to work with Android?
Also, bit of advice: if you plan to use this in a tabbed app and want the picker to show up in different tab views you'll have to modify the code to indicate what window you want it show in. My solution was to send the current active window in with the rest of the params and to remove the picker from the view after the closing animation. Works a treat.