Question

I have a problem that makes me headache since update to JQM1.4.2. If i try to close a dynamic popup, i become served this from logcat: "cannot call methods on popup prior to initialization"

I know i must initialize stuff first like so

$("#merkel").popup();
$("#merkel").popup("open");

How i do:

My HTML ..

<div data-role="popup" id="merkel" data-overlay-theme="b" data-theme="b">
    <ul data-role="listview" data-inset="true" style="width:180px;" data-theme="b">
        <li>another popup</li>
    </ul>
</div>

.. then open my popup from dynamic created html with a listview splitbutton:

<a class='splitbutton' href='#merkel' data-rel='popup' data-transition='none'>Options</a>

.. and fill the menu dynamically with content specific code because every listitem menu has its own ids

$('#mainPage').on('touchend', ".splitbutton", function(e) {
    [fill div tags with specific atributes]
});

.. the li-menu is opening correct and specific popups are working. everything is fine excerpt the close function. The menu should be closed when the secondary popups are submitted or canceled. this would be called from the secondary popup function:

$("[id^=merkel]").popup("close");

the following error is throwed:

"cannot call methods on popup prior to initialization"

I've tryed to initialize the popups on different ways, even to init and open them from a own splitbutton listener function. Nothing helps. Do you have an idea what can i do to close the menu?

Thanks for helping me (and others) out here!

Was it helpful?

Solution

Try $("#merkel").popup("close"); instead of $("[id^=merkel]").popup("close"); Normally add-on functions wont change id values of applying html elements instead it adds classes or new attributes to make view effects. So your first id selection itself will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top