Client side theme script not loaded



  • I could hardly restrain myself from biting into my desk out of frustration yesterday, trying to use Masonry on a custom page. My theme script file (nodebb-theme-themename/static/lib/themename.js) is correctly listed in plugin.json but not included in the minified nodebb.js.
    On the other hand (which is what troubled me), when I tried to include a script in the page itself that loads Masonry from a CDN and just initializes a masonry object, it kept being undefined.

    So maybe someone can tell me what is wrong here:

    $().ready(function(){
    $.getScript("https://cdnjs.cloudflare.com/ajax/libs/masonry/3.3.0/masonry.pkgd.js", function(){ console.log('Script has been successfully loaded!'); });
    var masonryTest = new Masonry(); 
    });
    

    that just gives

    // Uncaught ReferenceError: Masonry is not defined
    // (anonymous function) @ VM162:2
    // InjectedScript._evaluateOn @ VM117:883
    // InjectedScript._evaluateAndWrap @ VM117:816
    // InjectedScript.evaluate @ VM117:682
    

    Go ahead, try it yourself in the console at my site.
    I have the feeling I overlook the obvious...


  • GNU/Linux Admin

    Just a thought... this look promising...

    require(['https://cdnjs.cloudflare.com/ajax/libs/masonry/3.3.0/masonry.pkgd.js'], function(Masonry) {
      var masonryTest = new Masonry();
      console.log(masonryTest);
    });
    

    (Though I didn't pass a selector into the new Masonry(); call, so it errors out, but that should help.)



  • @julian Thanks, that works well! 😊 Though I still wonder why I cannot use my theme js... I took the skeleton for my theme for lavender and changed the name everywhere.. Have I forgot something?


  • GNU/Linux Admin

    It's possible, have you pushed the repo to GitHub so we can take a look at it?



  • @julian, here it is. Thank you for your time!


Log in to reply
 

Suggested Topics

| |