jqueryjquery-mobilejquery-mobile-panel

jQuery Mobile panel won't hide


I'm trying to add a jQuery mobile slide panel. I can get the slider to pop out which is triggered by an anchor link but it won't hide again. Do I need to add an addition jquery script?

<div data-role="page">

<div data-role="panel" id="mypanel">
    <h1>This panel won't disappear</h1>
</div><!-- /panel -->
<body>
    <div class="wrapper">
    <div id="temp-speech"><a href="#mypanel"><img src="images/speech_bub.png" /></a></div>
</div>

</div><!-- page -->
</body>

I've created an updated fiddle http://jsfiddle.net/AZLWd/


Solution

  • Upon opening a panel, checks for .ui-header (internal), .ui-content and .ui-footer (internal) to wrap them in .ui-panel-wrappr div. That div (.ui-panel-wrapper) receives open and close animation classes. If panel fails to find any of the aforementioned div's, the close animation classes won't be added and panel remains open.

    Panel widget:

    _getWrapper: function () {
         var wrapper = this._page().find("." + this.options.classes.pageWrapper);
         if (wrapper.length === 0) {
             wrapper = this._page().children(".ui-header:not(.ui-header-fixed), .ui-content:not(.ui-popup), .ui-footer:not(.ui-footer-fixed)")
                 .wrapAll("<div class='" + this.options.classes.pageWrapper + "'></div>")
                 .parent();
         }
         return wrapper;
     },
    

    In light of the above, any page should contain at least a header, footer or a content div in order to function as it should.

    <div data-role="page">
      <div data-role="panel">
        <!-- panel content -->
      </div>
      <div role="main" class="ui-content">
        <!-- contents -->
      </div>
    </div>