Angular ui-select2 - hide initial drawing/rendering of component

旧巷老猫 提交于 2019-12-11 13:19:24

问题


I'm evaluating using Angular with ui-select2 and wondered whether someone could provide help on hiding the flicker/conversion of the <select> into the select2 component.

It's only very brief, but users can see the component change styles.

Is there a way of hiding it until the select has been modified by select2?


回答1:


I came across the same problem and I had a look at the source code. The directive is deliberately initialised later by using a timeout. In the code there is a comment saying "Initialize the plugin late so that the injected DOM does not disrupt the template compiler".

My solution (you can see it in this jsplunker: http://plnkr.co/edit/fXjDxs?p=preview ) is to set the visibility of the select tag to "hidden".

<select ui-select2 ng-model="....." style="visibility: hidden; ">......

When the component is loaded that tag is replaced with a div. In ui-select2.js I have added a line (line 208) to set its visibility to "visible".

elm.prev().css({"visibility": "visible"});


来源:https://stackoverflow.com/questions/24999108/angular-ui-select2-hide-initial-drawing-rendering-of-component

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