Mismatched anonymous define() module error when using custom hyperlink handler

1

We are using a custom dashboard hyperlink handler taken from here:  https://community.jaspersoft.com/wiki/how-use-custom-hyperlink-handler-d...

After upgrading to 7.2, we are getting the following error in the browser console and the dashboard fails to load:

Error: Mismatched anonymous define() module: function(require)

I have consulted https://requirejs.org/docs/errors.html#mismatch and I feel like I followed the solution but it did not help.

The problem seems to be related to the order in which javascript modules are being loaded.

The error does not happen consistently. I can execute dashboards several times in a row without error before it happens.

I understand that RequireJS is a JavaScript file and module loader, but I know very little about javascript; so any suggestions for the layperson are welcome.

The custom handler code is below.

//define(function(require) {
define(["require","jquery", "underscore"], function(require) {
 
    "use strict";
 
    var $ = require("jquery"),
        _ = require("underscore");
 
    return {
        events: {
            click: function(event, linkData) {
                if (window.location.href.indexOf("dashboard/viewer") > -1) {
                    var hashParts = window.location.hash.split("&"),
                        reportUri = hashParts[0],
                        params = {};
 
                    for (var i = 1; i < hashParts.length; i++) {
                        if (hashParts[i].indexOf("=") > 0) {
                            var key = hashParts[i].split("=")[0],
                                value = hashParts[i].split("=")[1];
 
                            if (key in params) {
                                params[key].push(value);
                            } else {
                                params[key] = [value];
                            }
                        }
                    }
                    location.replace(reportUri + "&" + $.param(_.extend(params, linkData.parameters), true));
                }
            }
        }
    }
});

ktalarico's picture
553
Joined: Mar 19 2007 - 4:15am
Last seen: 5 days 9 hours ago

Note that other times you will get a jquery error: 

jQuery.Deferred exception: s is not a constructor TypeError: s is not a constructor

Solution below resolves both

ktalarico - 1 month 1 week ago

Thanks for sharing this and for updating https://community.jaspersoft.com/wiki/how-use-custom-hyperlink-handler-d... ! I upvoted question and answer :)

kkumlien - 1 month 1 week ago

1 Answer:

1

Solution provided by Tibco support:

Our engineering team investigated this and says that the issue seems to be caused by some strange behavior in require.js.  They say that the issue can be fixed by adding the module name in dashboardHyperlinkHandlerUpdateDashboardParams.js like this: 
 
replace 
 
define(function(require) {
 
with 
 
define("dashboardHyperlinkHandlerUpdateDashboardParams", function(require) {
ktalarico's picture
553
Joined: Mar 19 2007 - 4:15am
Last seen: 5 days 9 hours ago
Feedback
randomness