0

My issue is same with question How to manually toggle angular-ui-select dropdown, but in my case, i just use single select feature.

Generally, I'm using AngularUI's ui-select to create single select on a page. I need to be able to open the dropdown list when a user clicks on a button on the page.

I've tried using jQuery's .click(), .trigger('click') but they're not working.

This plunker has been forked with Singe Select Option:

http://plnkr.co/edit/0OKTgpURgAk7CCG0GIxC?p=preview

How can I toggle the dropdown manually, from outside the ui-select element's context?

Update:

  • In this plunker (plnkr.co/edit/7wXP6cSqPaDlvhEbkNau?p=preview), the version of ui-select is 0.9.x, they use the button to active the event, and we can use $("#"+attrs.openMenuByClick).find('button').click(); (Thank @sdfacre for this help)

  • The new version of ui-select is 0.13.2, they use the <span> instead <button>, so how can I call ng-click function when they use <span> without using directive?

http://plnkr.co/edit/0OKTgpURgAk7CCG0GIxC?p=preview

2
  • I think it would be good if you could edit your question to include the additional info present in the other question, just so it clearly stands by itself. Commented Jan 18, 2016 at 4:10
  • Hi @ajshort, the option is just changed from muliselect to single select. I have edited the question and put more info. Commented Jan 18, 2016 at 4:26

1 Answer 1

1

seems like with single select, the toggle control is on a button not an input.

so, try this

$("#"+attrs.openMenuByClick).find('button').click();

plunker is also available here http://plnkr.co/edit/r2Iufl9CcNRV6iozvWQj?p=preview

Sign up to request clarification or add additional context in comments.

10 Comments

It's not work. Did you test yourself on plunker and that worked?
interesting, I did test this on plunker. Anyway, sorry about that, I will paste the plunker link here later.
I might somehow mixed up something when I was testing it. I have fixed the answer and provided the link to plunker. please check. Sorry for the confusion.
Thank you. It works. But sorry so much, I didn't check the version of ui-select library when fork the plunker. In that plunker, version of library is 0.9.x. My real issue is on version 0.13.2. Sorry, it's my fault. I have updated the plunker on plnkr.co/edit/0OKTgpURgAk7CCG0GIxC?p=preview. Could you take a look for me again?
No problem. Your new plunker works for me, what would you like me to look exactly?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.