Skip to content

SAML Settings not properly initialized due to global jQuery conflicts #475

Open
@blizzz

Description

@blizzz

Steps to reproduce

  1. Use Nextcloud 20
  2. Have user_saml and, for instance, nextbackup enabled
  3. Go to SAML settings for fresh configuration

Expected behaviour

  • the SAML mode chooser should appear

Actual behaviour

  • only the section title is displayed, otherwise the page is empty

Logs

Browser log

Uncaught TypeError: $(...).tipsy is not a function
    <anonymous> script.js:113
    jQuery 6
    Webpack 6
script.js:113:27

^ script.js refers here to the nextbackup's js file (which should not be injected there anyhows).

A quick solutions is to detangle the initialization from jQuery:

diff --git a/js/admin.js b/js/admin.js
index c932053..0fb1384 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -117,7 +117,7 @@
    }
 })(OCA);
 
-$(function() {
+var samlInit = function() {
 
    var type = $('#user-saml').data('type');
 
@@ -407,4 +407,23 @@ $(function() {
            nextSibling.slideDown();
        }
    });
-});
+};
+
+function ready(callbackFunc) {
+   if (document.readyState !== 'loading') {
+       // Document is already ready, call the callback directly
+       callbackFunc();
+   } else if (document.addEventListener) {
+       // All modern browsers to register DOMContentLoaded
+       document.addEventListener('DOMContentLoaded', callbackFunc);
+   } else {
+       // Old IE browsers
+       document.attachEvent('onreadystatechange', function() {
+           if (document.readyState === 'complete') {
+               callbackFunc();
+           }
+       });
+   }
+}
+
+ready(samlInit);

the better approach is, of course, to webpack it and stay away from the global $.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions