0

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!

metamagikum
  • 1,307
  • 15
  • 19

1 Answers1

1

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.

viki
  • 1,178
  • 1
  • 17
  • 22
  • That's it, thank you! I am creating different menu structures depending on the listitem like "#merkel01, #merkel02 etc.". When i close them explicit instead of using a wildcard selector it works, but why? – metamagikum Mar 28 '14 at 04:57
  • The value should be in quotes for wildcard selectors (ie) $('[id^="merkel"]').popup("close"); or $("["id^='merkel']").popup("close"); – viki Mar 28 '14 at 05:06
  • That isn't it - see -> http://stackoverflow.com/questions/5376431/wildcards-in-jquery-selectors. They must be without quotes. But thank you, it's working now. – metamagikum Mar 28 '14 at 05:16