Including jQuery mixin file in plugin

NodeBB Plugins
  • Hi Guys! I've been writing a plugin for parsing a post for magic the gathering card names and loading an image of the card within the post.

    That works great, but now instead of loading the image directly into the post, I'd like to make a link to a lightbox where the image will be shown. So far I've parsed the post to replace card names with the anchor element, but I cannot properly load a jquery plugin.

    Focusing v0.8.x branch, you can find my current code here:

    Any help would be very appreciated..I have been on this for hours and I do not want to give up!

  • Used to be a big fan of MtG. Think I still have a Mox Diamond in my collection that I should probably just sell since its otherwise collecting dust.

    Anyways, can you be more specific as to what your problem is? You can't just add the jquery plugin js into your plugin.json script object?

  • @psychobunny thanks for the response! Sorry it took me a day to get back to you.And if you no longer play I'd happily take that Mox Diamond off your hands. ๐Ÿ™‚

    Anyway, my problem is that I cannot properly load the Stripjs library with my plugin. I've tried several ways to include the script into my application. Most of them end up with Uncaught Error: Mismatched anonymous define() module but when I used require.js in my main.js, a different error occurred which was the $ (jQuery) was undefined and the jQuery lightbox plugin I am using could not call $.extend. I doubt I'm explaining this properly as it half sounds like Greek to me. But I assume the staticDir in my plugin is being ran on page load before jQuery is loaded---that is why $ is undefined.

    I got so frustrated with it that I just wrote my own extremely simple lightbox with plain javascript and loaded it into my plugin, though I would still love to use the external library instead.

  • MTGsalvation has this functionality, but with an older tech backend. It is very important to the UX of a mtg related site. Best of luck!
    (I play Cheeri0s and Dredge in modern ๐Ÿ™‚ )

  • Uncaught Error: Mismatched anonymous define() module

    This one is a known pain point for NodeBB, hopefully something we can fix in 1.0 when we move off requirejs and use browserify instead.

    See the changes to imagesLoaded.js and masonry.js for how its done; you'll have to make a small modification to the library:

  • Thank you @psychobunny! I'll look into how to modify the library for that.

    @lulzdevlol Nice to see someone else using Dredge! That's my favorite mechanic.

Suggested Topics