Ember.Select with an unbound options list

て烟熏妆下的殇ゞ 提交于 2019-12-11 04:57:46

问题


In an ember.js application that I am working on (ember v1.8.0-beta1, ember-cli), I have a page with a simple sign-up type form that includes a country select dropdown. The problem is that since this field has a relatively large number of options (244 to be exact), there is a big rendering performance hit, the route takes almost a full second longer to render when that select field is added to the template.

I assummed that this slowdown was due to Ember having to create bindings for each of the 244 <option> views within the select, so following this cookbook entry that I found, I attempted to create an unbound version of Ember.Select like so:

app/views/unbound-select.js

import Ember from 'ember';

export default Ember.Select.extend({
    optionView: Ember.SelectOption.extend({
        templateName: 'unbound-option'
    })
});

app/templates/unbound-option.hbs

{{unbound view.label}}

app/templates/signup.hbs

...
{{view "unbound-select" value=country content=countries}}
...

However, doing this instead of using a regular Ember.Select does not seem to help with the rendering speed at all. Is there maybe something that I'm missing in my implementation that would be causing all the <option>'s to still be bound?


回答1:


Seeing as your unbound extension of Ember.Select is just as slow, I'd venture that Ember.Select is simply slow. From the docs, last paragraph:

The select view is extremely feature-rich, and may perform badly when rendering many items. Due to this, it has not yet been converted into an component or helper like other inputs.



来源:https://stackoverflow.com/questions/25814796/ember-select-with-an-unbound-options-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!