garethdn
garethdn

Reputation: 12351

jQuery mobile's pageinit causing problems on navigating back

My application which uses JQM has a search function for users which dynamically populates an autocomplete box. The server request activates after 3 character are inputted and then on each subsequent character. It works fine and allows the user to click a link in the autocomplete box and navigate to the page. On pressing the back button, however, the server call is never made when the third character is entered and i'm sure it's down to JQM's recommended use of $(document).on('pageinit').

How can I change this so that the search functionality is available to use after navigating back?

Upvotes: 0

Views: 317

Answers (1)

Red2678
Red2678

Reputation: 3287

I know you are using "on" but Pageinit only will fire once, when the page is first initialized.

You should bind your function to "pageshow."

$( '#theSearchPage' ).on( 'pageshow',function(event){

           ../Do Your Stuff
});

Upvotes: 1

Related Questions