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) {
- $.mobile.loading( 'hide' );
- data.deferred.reject( data.absUrl, data.options );
- //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):
- if ( settings.showLoadMsg ) {
- hideMsg();
- $.mobile.showPageLoadingMsg( $.mobile.pageLoadErrorMessageTheme, $.mobile.pageLoadErrorMessage, true );
- setTimeout( $.mobile.hidePageLoadingMsg, 1500 );
- }
- deferred.reject( absUrl, options );
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.
Thanks!