Newer Versions of Handsontable not working with Require.js

Hi!

I’ve been using Handsontable for the past 6 months. We’ve had it integrated in our product for a year, I believe. The version we are using is 1.10.x. We also use Require.js to load our JavaScript resources. We had no problem using this older version with Require, but I’ve recently attempted to upgrade to the latest version of Handsontable and it is not playing nice with Require. I get an error in the console when trying to create a new Handsontabe() : TypeError: Handsontable is not a constructor.

I’ve provided two samples in JsFiddle:

Working sample using older version (1.10):
https://jsfiddle.net/wsglasgowpwc/176gawqk/9/

Non-working sample using latest version:
https://jsfiddle.net/wsglasgowpwc/176gawqk/10/

Please advise on how we can get the newer version working with Require, since we need to take advantage of the new version with enhancements and bug fixes.

Thanks in advance for the support!

Regards,
Bill

Hi @william.s.glasgow

Have you seen this issue https://stackoverflow.com/questions/45780065/handsontable-v0-34-0-not-working-with-requirejs/45790769#45790769? It may be related to the same subject

Hi, Aleksandra,

I did see that post, and unfortunately it does not help. You’ll notice that the individual using Handsontable in the post was using an older version as well. Also, the JsFiddle I provided has the “H” as a capital, but still not working.

Require expects something to be returned from the .js file. In your 1.10 version, there is a return statement at the bottom. Newer versions do not return anything. Do you have any idea why this change was implemented in newer versions? Is there a workaround for us?

Thanks,
Bill

We have dropped a support for RequireJS, maybe that is why the code you’ve mentioned is gone. I am sorry but I do not think that we will be adding it back

Is there any solution or workaround for the requireJS? Because it is a mandatory requirement for us.
Thanks.

The support team provided us with this example which seems to work:
https://jsfiddle.net/j29ykt6d/8/

Cheers,
Bill

1 Like

Thank you for your help @william.s.glasgow

Thanks @william.s.glasgow. It worked.