Tuesday, June 26, 2012

jQueryMobile: ListView and Back Button

I'm not the only one who has a problem with Back button. Working on new mobile site, I started experiencing problem with Back Button presentation using ListView. It's completely gone when viewing a nested list submenu. I found a good solution on  StackOverflow.com.   It's quite sophisticated and smart code-snippet, which work very well.
Here it's
 <script type="text/javascript" language="javascript" type="text/javascript">
         $(':jqmData(url^=home)').live('pagebeforecreate',
        function (event) {
            $(this).filter(':jqmData(url*=ui-page)').find(':jqmData(role=header)')
            .prepend('<a href="#" data-rel="back" data-icon="back" data-theme="b">Back</a>')
        });

    </script>
Replace MYPAGEID with the ID of the page containing the list.
It should be added after jQuery initialization.

No comments:

Post a Comment