Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-16564

Initialization of annotations might fail in some situation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Solved By
    • Major
    • None
    • 9.8
    • Annotations
    • None
    • Unknown

    Description

      On the AnnotationCode.Script jsx, the way the annotations initialization code is written can cause in some case the initialization code to not be executed. Therefore, the annotations shortcuts and the 'Annotations' link on the 'More' menu will not work.

      Currently the code of the annotations intialization is something like :

      document.observe('xwiki:dom:loaded', function() {
        // Annotations initialization handler
      });
      

      The issue might appear when the AnnotationCode.Script script is loaded after the 'xwiki:dom:loaded' event is triggered, in this case the Annotations script will never observe the event and therefore never execute the initialization handler.
      To prevent the annotations initialization handler to never being called, the initialization hanlder need to be called properly as explained on the xwiki.org documentation : https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/JavaScriptAPI/#HDOMEvents28xwiki.js29.

      The annotations initialization handler code should be called this way:

      function init() {
        // This is your initialization handler, that you generally hook to xwiki:dom:loaded
      }
      (XWiki && XWiki.domIsLoaded && init()) || document.observe("xwiki:dom:loaded", init);
      

      Attachments

        Issue Links

          Activity

            People

              acotiuga Alex Cotiugă
              mouhb Mohamed Boussaa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: