Jquery mobile, init bind page events only once -
I am using jquery mobile v1.3.2
For some reasons I have a global PageChange The event is for preparing all my pages:
var Front = {initDom: function ($ dom)} {// Here I have some pages in my $$ The event can tie ".somebutton", $ dom) .bind ("tap", function () {warning ("some actions");}); // e.t.c..... }); } $ (Document) .on ("pagebange", function (event, data) {Front.initDom ($ (data.toPage));}); It works well but it is triggered on changes in each page. And sometime this will init the same event twice and it will lead to some bugs.
Now I get the event pageinit or pagecreate but both pages are triggered before the page is ready and $ ("ui-page-active "); is empty.
Although I have some set timeouts, but this is definitely a bad idea.
I have allocated everything for the first time on pageinit and opened it. But Ajax, which is called a page, will not be bound.
Is there some good work in it?
You can use Pageinit and then get the ID of the page from the event object object:
$ (document) .on ("pageinit", function (e) {alert (e.target. Id);});
Comments
Post a Comment