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

Set selected item from external code #15

Open
mucaho opened this issue Oct 23, 2014 · 3 comments
Open

Set selected item from external code #15

mucaho opened this issue Oct 23, 2014 · 3 comments

Comments

@mucaho
Copy link

mucaho commented Oct 23, 2014

How do I set the selected item (from external code) after acute-select is already loaded?

Changing the ac-model object to the desired id & name correctly updates the display when the drop-down menu is closed.
However, once you open the drop-down menu the item is not selected/highlighted.

@mucaho
Copy link
Author

mucaho commented Oct 23, 2014

This is similar to #11 .

The proposed solutions are:

  • the ac-model value has to be one of the values in the ac-options data (reference to the same object as in ac-options)
  • If it's a separate object with the same property values, you can use the ac-key property though (and make sure that both objects have the same ac-key property value)

Neither approach highlights the item in the drop-down menu. When user clicks that item (that should have already been highlighted before from external code) in the list, the item gets highlighted and a change event gets fired (but it shouldn't).

@alindzon
Copy link

binding appears to work except when I set the model back to null which should restore the box to the watermark, but it does not. Perhaps there is a fix for this?

I resolved this issue to set the model back to the watermark, set it to an object of nulls such as{ "name":null, "id": null};

@redBaronNc
Copy link

I have the same problem but your workaround doesn't seem to work for me. I tried assigning the model to { "name":null, "id": null}; But the select keeps the previously selected value.

I am using ac-settings="{loadOnOpen: true, loadOnCreate:false, comboMode:false, allowClear: true}" and ac-key="id".

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

3 participants