BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
855 stars 130 forks source link

multiselect onload not showing the selected options as selected #352

Closed kthanesh closed 7 years ago

kthanesh commented 7 years ago

Hi

In your sample code I see multiselect has selectedItems array. when the page is loaded why is the first multiselect box is not setting the selected option.

Thanks

Thanesh

kthanesh commented 7 years ago

I have added one more for loop for tag._optionsTmpl in multiselect.js so that "selected" attribute is set to the option tag. It worked.

BorisMoore commented 7 years ago

Hi Thanesh,

Good catch, thanks for calling this out. I have taken a look, and I think the issues is with the following lines:

https://github.com/BorisMoore/jsviews/blob/master/jsviews.js#L5125-L5126

which should be replaced by:

if (linkedElem && linkedElem[0]) {
    if (!tag.noVal && !tag._.chging) {

You should not need to change multiselect.js. The selection is set in this line:

https://github.com/BorisMoore/jsviews.com/blob/gh-pages/download/sample-tag-controls/multiselect/multiselect.js#L70

Let me know if this approach does not work for you, or if you see other issues.

Thanks!

Boris

kthanesh commented 7 years ago

Worked

Thank you for a quick reply.

Thanks

Thanesh

BorisMoore commented 7 years ago

This has been fixed on release v0.9.83