I have this js that beginning so:
$( "#map-page" ).live( "pageinit", function()
{
//Here the body function
});
I would load this function after the page has completed to load.how can i do?
I have this js that beginning so:
$( "#map-page" ).live( "pageinit", function()
{
//Here the body function
});
I would load this function after the page has completed to load.how can i do?
Update: Looks like this method won't work with jQuery mobile (strangely enough).
Try this instead:
$(document).ready(function () {
$("#map-page").doWhatever();
})
For what you want, I think that load suits better
You can read about it here http://api.jquery.com/load/
You should be more clear that you're referring to jQuery Mobile, anyways the best way is to bind a live event to the pagecreate/pageshow event that's triggered on the <div data-role="page">
If you want the code to run just once use pagecreate, if it needs to run everytime the page is shown (there is dynamic data) then use pageshow and fetch any changes via AJAX. Please note if you re-navigate to the page again via the back button etc, it may be fetched from memory in which case your html won't be updated - you must use non-AJAX loading or update your DOM via AJAX in the pageshow
Use an id or class to properly attach the listener, here's a more detailed answer I wrote: https://stackoverflow.com/a/9085014/737023