Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Modal Picker

Hi all. I thought I'd share some code with you:


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) {
    picker_initialized = true;

  data = [...some data...];
    data: data,
    on_select: function(e) {
      var title = modalPicker.picker.getSelectedRow(0).title;

      ... do something ...



…hope that helps someone.

— asked November 29th 2010 by John Williams
  • modal
  • picker

2 Answers

  • I think is adapted from my post here http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/ :)

    — answered November 29th 2010 by Dan Tamas
    1 Comment
    • Yes, that was it… thanks for posting that. I wanted you to get credit.

      — commented November 29th 2010 by John Williams
  • 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.

    — answered July 16th 2011 by Russell Morgan
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.