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.

md-select doesn't work for dynamic options

See original GitHub issue

The underlying framework supports this but ember-materialize doesn’t perform the required javascript call when the ‘content’ field on md-select changes.

Workaround: create an observer in your application that calls the necessary javascript function to rebuild the md-select’s ul/li list Eg.

  _selectRefresher: Ember.observer('_fields', function () {
    // ember-materialize does not perform the refresh needed by the Materialize CSS framework
    Ember.run.next(() => {
      Ember.$('select').material_select();
    });
  }),
    {{md-select
      content=_fields
      value=_selectedFieldPriorityId
      optionLabelPath="content.translation"
      optionValuePath="content.key"}}

The fix for this issue is simple. Inside the md-select component this observer should exist so that the application using the addon doesn’t need to do it themselves. I’m under a deadline right now and don’t have time to create a PR but if someone doesn’t get around to this at some point I’ll hopefully have time to make the PR myself. Mainly added this so that people that are having the same problem will know the work around.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
EWhite613commented, Feb 14, 2017

I ran into this problem as well.

Using the following works like a charm:

export default materializeSelect.extend({
  didRender() {
    this._super(...arguments);
    this.$('select').material_select();
  }
});

@DanLatimer is issue based on adding new options or modifying options? If the later could probably add dependent dynamic keys, explained here

0reactions
mitchirucommented, Feb 22, 2017

@EWhite613 I found the same solution appropriately working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material md-select does not show selected Item (bind ...
I already tryed that. It did'nt work. And what's funny, when I put "{trackBy: '$value.id'}", it initiates selected the both items, but them...
Read more >
Dynamic population of md-select not working #1334 - GitHub
I'm trying to create a component around md-select that dynamically creates the content list after the component is first instantiated.
Read more >
Directives > mdSelect - AngularJS Material
Parameter Type Description * ng‑model expression expression Assignable angular expression to data‑bind to. placeholder string string Placeholder hint text.
Read more >
Angular Material Mat Select Dynamic Data Binding ... - StackBlitz
Select with 2-way value binding. ... <mat-option *ngFor="let education of. educationList" [value]="education. educationLevelName" >{{ education.
Read more >
Dynamically alter options in mdb-select
The above works fine in regular Angular, but when I convert to mdb-select using a dynamic collection, it doesn't update based on ngIf....
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