Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

adding ability to disable a ui-select by setting its ancestor fieldset's disabled property #415

Closed
wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 19, 2014

Disabling the root ui-select element works just fine, however something like this:

<fieldset disabled>
    <ui-select ...>
        ...
    </ui-select>
</fieldset>

does not disable the ui-select control.

my changes to the code make this work.

@AdamAxtmann
Copy link

Alternatively, adding a watch on the focusser works without doing DOM traversal.

    attrs.$observe('disabled', function() {
      // No need to use $eval() (thanks to ng-disabled) since we already get a boolean instead of a string
      $select.disabledFlag = attrs.disabled !== undefined ? attrs.disabled : false;
      $select.disabled = $select.disabledFlag || $select.disabledSelector;
    });

    scope.$watch(function () { return focusser.is(":disabled"); }, function (value) {
      $select.disabledSelector = value;
      $select.disabled = $select.disabledFlag || $select.disabledSelector;
    });

Then we just remove ng-disabled from the input element.

    //Don't disable this field, since it's css selector (:disabled) is being monitored to identify if it's in a fieldset.
    var focusser = angular.element("<input class='ui-select-focusser ui-select-offscreen' type='text' aria-haspopup='true' role='button' />");

See my pull request here: #445

@buraktamturk
Copy link

Any good reason for not merging this? This is definitely must have feature for a form element. I can control all of my form fields using fieldset except ui-select, in case I need to add same ng-disabled expression to ui-selects. Just why?

@portus84
Copy link

+1

2 similar comments
@Sheeryada
Copy link

+1

@eugeneos
Copy link

eugeneos commented Dec 7, 2015

+1

@AdamAxtmann
Copy link

This hasn't been merged because it's failing build tests. See #772 for a working fix.

@wesleycho
Copy link
Contributor

Closing due to being superceded as mentioned in comments & due to age.

@wesleycho wesleycho closed this Apr 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants