question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chosen doesn't update when the model changes programmatically

See original GitHub issue

If you are going to be lazy asking me properly, I’ll be lazy answering to you (@leocaseiro)

Please make sure you can mark all the options, before open this Issue. I’ll prioritise the issues that are consistent and completed.

Please, post your plunker link here:

plunker

Write your issue:

As can be seen in the attached plunker, clicking the button, which updates the model value, does not result in chosen itself getting re-rendered. This seems to be because of this line in the code. At least when I’m looking at it, the .css() call always returns a value of 0px, even when the dropdown is closed, which prevents the updated event from getting triggered.

I have no problem creating a PR, but I’m just not sure what that line of code is trying to accomplish. Would it be enough to test whether the dropdown is open (e.g. by checking if the active class is applied)?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
abyxcommented, Jul 20, 2017

Opened pull request #245 will appreciate feedback

1reaction
VanTanevcommented, Jul 7, 2017

My intuition is that we should remove the overwritten ngModel.render and the CSS hack and instead add something like:

ngModel.$formatters.push(function(value) {
  initOrUpdate()
  return value
})

The idea is that formatters are called only when angular changes the expression, while ngModelCtrl.render() is called both when angular chances it, and when chosen changes it

This is just a guess off the top of my head, haven’t had the chance to think through it very deeply.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angularjs - Select box not updating when model is changed ...
If you change the value of the select using the JQuery function ( .option() ) for selectmenu , it updates the select box...
Read more >
SCR19: Using an onchange event on a select element ... - W3C
The objective of this technique is to demonstrate how to correctly use an onchange event with a select element to update other elements...
Read more >
select - API Reference - Kendo UI DropDownList
The model bound to the widget will not be updated. You can overcome this behavior trigerring the change event manually using trigger("change") method....
Read more >
Modifying a stack template - AWS CloudFormation
If your template includes an unsupported change, AWS CloudFormation returns a message saying that the change isn't permitted. This message might occur ...
Read more >
Programmatic Modeling Basics - MATLAB & Simulink
Loading a model brings it into memory but does not open it in the Simulink Editor for editing. After you load a model,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found