• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 4.x Series
    • Bug
    • [4.1 Beta 2] VaultWiki javascript uncaught TypeError on non-wiki pages when opening menu (XF menu click handler)

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: [4.1 Beta 2] VaultWiki javascript uncaught TypeError on non-wiki pages when opening menu (XF menu click handler)

    • Issue Tools
      • View Changes
    1. issueid=5795 July 18, 2019 8:00 AM
      ACL ACL is offline
      Regular Member
      [4.1 Beta 2] VaultWiki javascript uncaught TypeError on non-wiki pages when opening menu (XF menu click handler)

      On non-VW pages, attempting to open menus (with XenForo's standard data-xf-click="menu" handler) will sometimes fail. The following error is written to the browser console:
      base.js:7 Uncaught TypeError: Cannot read property 'setData' of null

      Code:
      $(document).on("xf:reinit", function(a, d) {
              var b = d;
              b instanceof $ && (b = b.get(0));
              b = Y.Node.one(b);
              b.setData("js-exec", 1);
              vw_Hard_Core.trigger_dom(b)
          })
      The file is js/vw/vw/xf2/compiled/base.js.

      With the VaultWiki addon disabled, menus always open as expected. Commenting out "b.setData("js-exec", 1);vw_Hard_Core.trigger_dom(b)" also stops the uncaught type error.

      The page that I experience this on is from another addon. That addon implements XenForo's menu click handler in an XenForo template in order to allow moderators to check/uncheck items (of a custom content type) for inline moderation. I've worked around this particular instance by adding the following line of html to the template, within the menu element. With the below addition, var b is no longer null.
      Code:
      <div class="js-menuBuilderTarget"></div>
      In the standard XF template member_view, the stock "Moderator tools" menu opens normally without the above js-menuBuilderTarget html. It seems that the javascript where the type error occurs is not executed on this page. Was it intended that js/vw/vw/xf2/compiled/base.js should run on non-wiki pages?
    Issue Details
    Issue Number 5795
    Issue Type Bug
    Project VaultWiki 4.x Series
    Category Forum Posts / Non-Wiki Content
    Status Forum Bug
    Priority 6 - Dev-Related Tasks
    Affected Version 4.1.0 Beta 2
    Fixed Version (none)
    Milestone (none)
    Software DependencyXenForo 2.x
    License TypePaid
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. July 18, 2019 10:24 AM
      pegasus pegasus is offline
      VaultWiki Team
      I suspect this occurs because the menu in question is a menuBuilder (loads via asynchronous request). If it is such a menu, and it works correctly after adding the aforementioned class, then that may be the solution. As you can see from the code, VaultWiki does not discriminate by class here, but it expects that XenForo is passing an actual element to the xf:reinit event. In this case, XenForo did not pass one; I'm guessing because it could not find the menu contents due to being a menuBuilder that didn't have its Target defined.

      In fact, this is the way XF.MenuBuilder is written:
      Code:
      		actionBar: function($menu, $target, handler)
      		{
      			var $menuTarget = $menu.find('.js-menuBuilderTarget');
      			...
      			XF.activate($menuTarget);
      		}
      XenForo does not test that $menuTarget actually exists, before 'activating' it (and triggering the xf:reinit event). It expects that it does exist.
      So here, the bug is either that XenForo expects $menuTarget to exist when it doesn't need to exist for every MenuBuilder, or that it must exist and the menu you've clicked has a bug by not defining one.

      Regarding compiled/base.js running on non-wiki pages: this is intentional. The minimal VaultWiki JS must run on pages meeting certain criteria so that our xf:reinit callback is listening, in case an asynchronous event loads wiki content (such as an AJAX preview link), a wiki-related BB-Code needs its Javascript functionality (especially BB-Codes posted via quick reply after the page already loaded), or other cases. The compiled JS won't run on every single page, but certain contexts do trigger it (e.g. BB-Code being rendered).
      Reply Reply  
    2. July 18, 2019 11:11 AM
      ACL ACL is offline
      Regular Member
      Thank you for taking the time to provide this detailed information.

      As you mentioned XF.MenuBuilder, I've taken another look at the addon template. It doesn't currently contain any relevant items that menu builder is looking for, so I've reverted my earlier workaround and instead removed the data-menu-builder attribute. This has fixed the type error and now the menu opens happily.

      The page in question does contain a rich text box which does sometimes contain standard bbcodes (B, I) so that would explain the purpose of VW's base.js on this addon's pages.

      Thanks!
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 7:28 AM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2025 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
    Copyright © 2008 - 2024 VaultWiki Team, Cracked Egg Studios, LLC.