Last week I blogged about the fact that select2 v4 used define.amd and because of that dojo screws up the jQuery plugin.
This has been a significant issue – not hard to deal with but comes up all the time for XPages eedevelopers.
In the blog post comments Ferry Kranenburg posted a link to a solution he uses which is also an XSnippet. It is brilliant.
What he does in the XSnippet is:
- duplicates define.amd to define._amd
- deletes define.amd
- loads the AMD enabled jquery plugin (successfully)
- duplicates define._amd back to define.amd
- deletes define._amd
Rather than post the code here I want you all to go to the XSnippet and get it from there – and vote it up while you are there.
Personally I would prefer not to use <xp:this.resources> or at best use them wisely and you could easily write this without using resources should you so chose.
Big Problem – simple and elegant solution – well done Ferry and thanks for Sharing
Now go vote up his XSnippet !!!
You can shorten this by dropping the computed SSJS part ( => ${javascript:””} ): In a CSJS resource, the code can be added directly as plain JavaScript
Oh certainly – thanks for the comment 🙂 – for the sake of the example I like it as the XSnippet because for someone unfamiliar with the issue I think it is clearer on how it works
[…] Roden wrote a post about a solution a while ago which was inspired by a x-code snippet Ferry Kranenburg […]
Yes it is an old post but still helps a lot. I spent more than two days to identify this issue. Now I am happy!!!
Thank you