I want to validate whether the approach I am taking with error messages is crazy, or if it's within reason.
My understanding of jquery mobiles page error handling is the following:
jQueryMobile has a default way of notifying the user that a pageload failed. By default it comes up with "Error Loading Page".
The following are the only interactions a developer using jQueryMobile has with these errors.
1) Changing the text/theme in mobile init
$(document).on('mobileinit', function () {
$.extend($.mobile, {
pageLoadErrorMessage: 'blah',
pageLoadErrorMessageTheme: 'b'
});
});
2) pageloadfailed event
$(document).on('pageloadfailed', function (event, data) {
//ok, i know it failed, now what? reject the promise? prompt my own error? change the global error message here?
});
It would seem that there isn't a more convenient way of interacting with the error? Is the expectation in option 2) that you'll change the global error message inside the event?
I want to change the error message based on the situation, because sometimes I have context information that I want to provide a user which is more than "Sorry, we're having issues" or "Error Loading Page".
The approach I am taking at the moment is this:
$(document).on('pageloadfailed', function (event, data) {
//do my own thing here, alert with a popup with options
});
It essentially follows what the jquerymobile code does internally anyway, but with my custom error popup instead of the default one. Here's the jqmobile (1.2) code (lines 3741-3753, comments removed):
I know there is that "showLoadingMsg" option, but I still want the general ajax loader and i'm not sure there is a way to change this behavior when clicking on a link (seems to only be available when calling #changePage directly).
Anyway, sorry about the long post. But the ultimate goal is to see if what I am doing is reasonable, or totally insane.
As some background, I have a jQuery Mobile app where each url is fully loadable as jquery html pages, but they also have the capacity to return a json response instead.
Is there any way to tap into jQuery Mobile's url changing functionality without actually transitioning to a new page? I know that isn't a very jQuery Mobile-ish thing to do, but jQuery Mobile has really nice cross-browser url changing behavior, and there are a couple places where I would like to load some content, change the url, but not actually change the page (particularly since the app behaves like a single page app overall, so there are times where there is a ton of redundancy in reloading the entire page).
I know about #changePage() and #loadPage(), but change page is a full page change (not what I want) and #loadPage doesn't change the url (plus, i'm looking for a slimmer json response in these cases, and loadPage is gonna load the whole html payload and inject it into the DOM).