Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I achieve disabled state for the dropdown? #22

Closed
zukilover opened this issue Aug 21, 2014 · 8 comments
Closed

How can I achieve disabled state for the dropdown? #22

zukilover opened this issue Aug 21, 2014 · 8 comments

Comments

@zukilover
Copy link

The title says it all. Those jQuery plugins have it, is there any chance that it will be implemented to this too? How can I achieve such effect for now?

@DhruvPrakash
Copy link

I too was in need of this feature. In the end I simply modified the dropdownMenu directive to get what I needed. I'm still a novice at angular so my approach may seem kinda clunky, but this is what I did:
1)I added another property to the isolate scope of the dropdownMenu directive called showDropDown:

 scope: {
        dropdownMenu: '=',
        dropdownModel: '=',
        dropdownOnchange: '&',
        showDropDown: '='  //I added this part
      }

2)I added an ng-show to the template variable and set it equal to showDropDown

template = "<ul ng-show='showDropDown' class='dropdown'>\n    <li ng-repeat='item in dropdownMenu'\n        class='dropdown-item'\n        dropdown-item-label='labelField'\n        dropdown-menu-item='item'>\n    </li>\n</ul>";

3)In my controller I had a true/false variable called dropdownEnabled(my controller and not the directives controller property):

$scope.dropdownEnabled = true;// or false depending on if you want to enable or disable the dropdown

4)In my html where I needed the dropdown I added the new property show-drop-down apart from the other existing properties and set it equal to dropdownEnabled.

 <a href=''    show-drop-down='dropdownEnabled '  dropdown-menu="ddMenuOptions" dropdown-model="ddMenuSelected"  dropdown-onchange="dropDownItem(selected)">Open Dropdown</a>

@jseppi
Copy link
Owner

jseppi commented Aug 21, 2014

@DhruvPrakash thanks for the answer!
If you'd like to submit a pull request with your modifications I'd be happy to include it into the module.
One small request: change the showDropDown property to be called dropdownDisabled and change ng-show='showDropDown' to ng-hide='dropdownDisabled'

@yarivdev
Copy link

anything new? this would be a very nice addition.

@jseppi
Copy link
Owner

jseppi commented Mar 29, 2015

Pull requests are welcome!

@jseppi
Copy link
Owner

jseppi commented Jun 3, 2015

As of version 1.2.0, the dropdown-disabled setting has been added thanks to @Chinokao.

@jseppi jseppi closed this as completed Jun 3, 2015
@asso1985
Copy link

Seems like not working to me, is not disabled if i put dropdown-disabled="true" or false

@jseppi
Copy link
Owner

jseppi commented Jan 20, 2016

@asso1985 can you make a jsFiddle showing your problem? It seems to work on my example page http://jseppi.github.io/angular-dropdowns/ (click the Disable All) button.

@asso1985
Copy link

Just checked my package.json and found out this :

"name": "angular-dropdowns",
"version": "1.1.0",

Seems like i'm running version "version": "1.1.0", that might be the problem.

That was the problem, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants