Using a script with Require.js support.
-
Hello I'm trying to include jscrollpane.js on my theme and it's working but one of the dependencies mousewheel.js
https://github.com/brandonaaron/jquery-mousewheel
Is not, I've got an error in console
Uncaught Error: Mismatched anonymous define() module: function (a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelD...<omitted>...ch
And when I delete the part with define
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}
It's not working too.The thing is when I'm using it on a website the traditional way I don't have any problems but it seems that there's a conflict with the way NodeBB loads js files and uses require via
plugin.json
Do you have any idea of how I could fix this ?
-
Well personally I just cheat a bit and modify the file because it's so much easier to do:
https://github.com/psychobunny/nodebb-plugin-toastr/blob/master/static/lib/toastr.js#L332-L340
But the proper way of doing it would be like:
https://github.com/NodeBB/nodebb-theme-lavender/blob/master/static/lib/lavender.js#L2-L5
-
@psychobunny Cheers it worked perfectly I used the simpler method
-
Thank you for referring me on this topic @psychobunny
I was trying to figure it out but no success.
I want to implement isotope in my theme and this is what i used https://github.com/metafizzy/isotope/blob/master/dist/isotope.pkgd.js . So I did next:- I made two files:
- isotope.js where i putted the code from github I linked above and
- main.js where i putted code like this http://screencast.com/t/hzOQQJsq
- In my plugin.json I added those correctly i believe, http://screencast.com/t/MQYZAVwSrdd
And then it shows an error http://screencast.com/t/nYlVaPbtej . I am not sure what I have to do to fix this. Any help? @esiao
- I made two files:
-
@julian I delete that line like you said so this is left http://screencast.com/t/m27giXBBf . Now it doesn't show the first huge error like before, just these two http://screencast.com/t/bjsb13UHJXTj . I think that this second error is because of my main.js file but I don't know what exactly is problem.
-
@Jelena This error exist because Isotope is not defined. It seems that you did what @psychobunny said and @julian too but are you sure you load the correct file ?
Because t.Isotope is in Isotope minified version and the one you modified is not minified.
Look in your plugin.json that the correct file is called.The second error is directly linked to the first, because Isotope didn't initiate the function .isotope too.
-
@esiao I checked, and i am calling the correct file. Here is how my isotope.js looks like after i deleted what @julian told me http://pastebin.com/YPYs63T9 . I am not sure but I think that nodebb minify files automatically and that is why that happens. Can someone confirm? @psychobunny @a_5mith
-
This one is a little bit more complicated because there's several definitions going on in that file.
Case in point: https://github.com/metafizzy/isotope/blob/master/dist/isotope.pkgd.js#L1648-L1664
You'd have to do it the proper way as outlined some point above. I can give you a hand, do you have a copy anywhere I can clone and try and debug?
-
@psychobunny I added you for a collaborator on my github project so there you can see everything you need.