Suda
Posts: 0
Joined: Sat Oct 11, 2014 9:11 pm

Issue in loading the same page on click event

Hi

I'm having a page defined in a way it uses the local storage value in the page elements. I have a button and when I click it, I change the local storage value and try to load the same page. I expect it to reload with the new local storage value I set. I know this won't work with the normal page navigate option, so I used the following Java script:

$.mobile.changePage("ItemListPage.html", {
allowSamePageTransition: true,
transition: "slide",
reloadPage: true
});

This reloads the page without any issues and I can see the local storage value being changed to the new value- but the page doesn't load the elements properly. Do you find any issues in my approach given above? Could you give some idea in this regards Pls? Thanks.

Suda
Posts: 0
Joined: Sat Oct 11, 2014 9:11 pm

Issue in loading the same page on click event

By adding logs, I found that the service which is supposed to invoked on the pageShow is not called when using the above java script. Any suggestion which event I need to use so that the jQuery changePage() function will trigger the event to Invoke the service?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Issue in loading the same page on click event

Hello Suda,

To be honest, transition to the same page is not a good idea. After this transition, various problems are going. You should better call the event you need, such as load or show page, and don't make the transition.

Suda
Posts: 0
Joined: Sat Oct 11, 2014 9:11 pm

Issue in loading the same page on click event

Ok, Thanks for that. I can stop the transition, but could you pls advise how can I trigger the page load/ page show event forcefully? Can I do that using Java script? Any sample code pls?

The jQuery changePage() is not triggering pageShow/ pageLoad events as I can see.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Issue in loading the same page on click event

Hi Suda,

You can use following code to trigger "page show" event handler.

pre

//Where "test" is page name.
jQuery("#test").trigger("pageshow");

/pre

Regards.

Suda
Posts: 0
Joined: Sat Oct 11, 2014 9:11 pm

Issue in loading the same page on click event

Thanks Yurii, That worked with page show! But I'm having the old data a while until the new service get called and update the page elements. So I'd prefer if I could trigger page load event.

I tried with trigger("load"); but it didn't work. Could you advise the code to trigger page load event please? Thanks!

Suda
Posts: 0
Joined: Sat Oct 11, 2014 9:11 pm

Issue in loading the same page on click event

Could anyone help whether it is possible to trigger the page load event? If so, the code sample pls? I tried with these two codes, which didn't work.

jQuery("#test").trigger("pageload");
jQuery("#test").trigger("load");

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Issue in loading the same page on click event

Hi Suda,

Unfortunatly there is no available interfaces to trigger this event without pager reinit processing.

Here is code with page reinit current page processing:

pre

var currentPage = jQuery.mobile.activePage.attr('id');

var initPageFunction = currentPage + "_js";

try{
selfinitPageFunction;
}
catch(e){
console.log("initPageFunction, something wrong");
};

/pre

Regards.

Return to “Issues”