I have a hybrid mobile app using jQuery Mobile. At one point, in iOS, it loads a Modal window which contains a drop down box. I have a JavaScript function, in another file, that populates the drop down with different options, depending on a parameter. This works fine in Black Berry because it uses another page, instead of a modal, but in iOS the function to fill the drop down doesn't execute, I'm guessing its running before the the modal.
So I was reading about it and I think I need to use a Callback.
The modal gets initiated with:
app.modal.init(app.views.MODAL_REJECT);
I had tried to just call the function after it
getDropDownOptions(app.myvar);
But that didn't work.
How would I use a Callback in this case? I read about it but I really don't understand how to apply it.
Thanks
More Info / Update:
Something like this?:
fromBT: function () {
if (hwc.isIOS()) {
var _callback = function () {
mySelect = $('#reason-code');
myOptions = {
1: 'AAAA',
2: 'BBBB',
3: 'CCCC',
};
$.each(myOptions, function (val, text) {
mySelect.append(
$('<option></option>').val(val).html(text)
);
});
}
app.modal.init(app.views.MODAL_WINDOW(_callback));
} else if(hwc.isBlackBerry()){
app.loadPage(app.views.BB_PAGE, true);
}
}
So fromBT is called by a button, if is iOS I open a Modal window, but I want to add options to a select/dropdown inside the modal window.