Page 1 of 1

Issue in loading the same page on click event

Posted: Thu Oct 23, 2014 12:48 pm
by Suda

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.


Issue in loading the same page on click event

Posted: Thu Oct 23, 2014 1:06 pm
by Suda

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?


Issue in loading the same page on click event

Posted: Thu Oct 23, 2014 1:07 pm
by Evgene Karachevtsev

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.


Issue in loading the same page on click event

Posted: Thu Oct 23, 2014 1:20 pm
by Suda

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.


Issue in loading the same page on click event

Posted: Thu Oct 23, 2014 11:01 pm
by Yurii Orishchuk

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.


Issue in loading the same page on click event

Posted: Sun Nov 09, 2014 5:38 am
by Suda

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!


Issue in loading the same page on click event

Posted: Sun Nov 09, 2014 9:35 pm
by Suda

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");


Issue in loading the same page on click event

Posted: Mon Nov 10, 2014 4:19 am
by Yurii Orishchuk

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.