Puneet Duseja
Posts: 0
Joined: Wed Apr 16, 2014 10:55 am

Error Message when internet not available

Hi,
My application works only when internet connection is available. So when user clicks on any buttons, i need to check if internet is available on the divice and if yes app will work fine and if not give a prompt/error message," Please connect to internet".
Pls let me know how can this be done or is there any default message already?

Thanks

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Error Message when internet not available

Hi Puneet,

You will need to add Offline event handler to each app page. If fires when you lose the Internet connection.

Puneet Duseja
Posts: 0
Joined: Wed Apr 16, 2014 10:55 am

Error Message when internet not available

Hi Katya,
Thanks!
Could you please guide me how can i do that, it would be great if you can share code for the same.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Error Message when internet not available

Puneet,

Add Offline event handler: prelocalStorage.setItem("online", "false");/pre
And Online event handler: prelocalStorage.setItem("online", "true");/pre
For all buttons add this Click event handler:pre$('[data-role="button"]').on("click", function(){
if (localStorage.getItem("online") == "false"){
alert("Please connect to internet");
}
});/preThis is to check the variable and display a message if needed. You can add it as custom JS or on page Load event.

Puneet Duseja
Posts: 0
Joined: Wed Apr 16, 2014 10:55 am

Error Message when internet not available

Thank you!

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

Error Message when internet not available

hello!
Im using grids and images instead of buttons...Can I use this code too?
I mean data-role="grid" ?

Thanks!

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Error Message when internet not available

Hello,

There isn't "data-role=grid" attribute. In this case you should add this event listener on your image component.

Return to “Issues”