Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions controllers/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ else {
* Generate and populate the optionsDialog.
*/
function populateOptionsDialog() {
var selectedIndex = undefined;
var selectedIndex;
var options;

// Convert the object into array pairs.
pickerValueArray = _.pairs(args.pickerValues[0]);
Expand All @@ -87,12 +88,18 @@ function populateOptionsDialog() {
selectedIndex = getKeyIndexFromPairs(pickerValueArray, args.selectedValues[0]);
}

// Create an options dialog.
optionsDialog = Ti.UI.createOptionDialog({
options = {
options: pickerData,
buttonNames: ['Cancel'],
selectedIndex: selectedIndex
});
buttonNames: ['Cancel']
};


if(selectedIndex !== null) {
options.selectedIndex = selectedIndex;
}

// Create an options dialog.
optionsDialog = Ti.UI.createOptionDialog(options);
optionsDialog.show();
optionsDialog.addEventListener('click', done);
}
Expand Down Expand Up @@ -200,7 +207,11 @@ function getSelectedRowTitle(index) {
*/
function getKeyIndexFromPairs(pairs, key) {
pairs = pairs || [];
key = key || null;

if(typeof key === 'undefined') {
key = null;
}

var rowIndex = null;

// Determine index.
Expand Down