frequent
frequent

Reputation: 28523

Jquery Mobile - pagebeforehide - can't get event to fire

I'm trying to fire an event in JqueryMobile when navigating within a multipage. I can't get the event to fire. Anybody can help?

<div data-role="page" id="mainPage">
    <div data-role="content">
            <p>Content</p>
            <p>View internal page called <a href="#2ndPage">2ndPage</a></p>
    </div>   
</div>

<div data-role="page" id="2ndPage">
    <div data-role="content">
            <p>SubContent</p>
            <p><a href="#mainPage">MainPage</a></p>
    </div>
</div>

And my script:

$('#mainPage').bind('pagebeforehide', function (event, ui)
             {
             alert ("leaving MainPage");
             });

Thanks for helping!

Frequent

Upvotes: 2

Views: 2223

Answers (2)

Peacemoon
Peacemoon

Reputation: 3328

you should use "live" instead of "bind"

$('#mainPage').live('pagebeforehide', function (event, ui)
{
    alert ("leaving MainPage");
});

Upvotes: 3

Matt Fisher
Matt Fisher

Reputation: 241

I just ran into this issue as well. No where in the source of my jquery.mobile-1.0a4.1.js is there any mention of "pagebeforehide".

I have a feeling this hasn't been integrated in the current release yet.

Upvotes: 0

Related Questions