Implicitly submit the selected label if its the only form element
authorAlexander Ebert <ebert@woltlab.com>
Thu, 31 Jan 2019 17:44:44 +0000 (18:44 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 31 Jan 2019 17:44:44 +0000 (18:44 +0100)
wcfsetup/install/files/js/WCF.Label.js

index d41a1ddb319ff75f238de8e5e92e7a874a76cfca..21ad0901bb7a8a6f5f2321f1410c56b26c60d2ea 100644 (file)
@@ -280,6 +280,16 @@ WCF.Label.Chooser = Class.extend({
                // replace button
                label = label.find('span > span');
                $group.find('.dropdownToggle > span').removeClass().addClass(label.attr('class')).text(label.text());
+               
+               // Submit the form if the label chooser is the only form element.
+               if (!onInit && this._container[0] && this._container[0].nodeName === 'FORM') {
+                       if (elBySel('input:not([type="hidden"]):not([type="submit"]):not([type="reset"]), select, textarea', this._container[0]) === null) {
+                               setTimeout((function () {
+                                       this._container.trigger('submit');
+                                       //this._container[0].submit();
+                               }).bind(this), 100);
+                       }
+               }
        },
        
        /**