1

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.

Diomedes
  • 634
  • 11
  • 24
  • are you using jQuery Mobile? – Omar Jan 08 '14 at 18:06
  • are you using popup with dropdown menu? or `data-native-menu="false"` on `select`? – Omar Jan 08 '14 at 18:28
  • To be honest, not totally sure. I didn't write the application, just updating. Worst, I don't have an iOS mobile yet, so I can't see what it looks like, someone else, in another office, its looking at it and describing. But the Modal is coming up after pressing a button. – Diomedes Jan 08 '14 at 18:54
  • because it's not obvious whether its a jqm problem. – Omar Jan 08 '14 at 18:57
  • I know. I tried everything. I can't debug either. But I think at that point, in app.modal.init If I can execute my function, after the modal load, it would work. Any ideas? – Diomedes Jan 08 '14 at 19:07
  • selectmenu isn't appearing? – Omar Jan 09 '14 at 10:19
  • Its a select, its showing up, but it's not getting filled with the options. – Diomedes Jan 09 '14 at 16:10
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/44898/discussion-between-omar-and-diomedes) – Omar Jan 09 '14 at 16:11

0 Answers0