Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Initialize with a selected option #331

Closed
sevenam opened this issue Jul 18, 2017 · 3 comments
Closed

Initialize with a selected option #331

sevenam opened this issue Jul 18, 2017 · 3 comments

Comments

@sevenam
Copy link
Contributor

sevenam commented Jul 18, 2017

Issue #33 was re-introduced with release 1.3.0 and the "_checkTruncation" method.

Unable to populate the dropdown with the selected attribute set.

@sevenam
Copy link
Contributor Author

sevenam commented Jul 18, 2017

As far as I can see, adding the following statement to the constructor of Dropdown.ts should fix it:

if(option.selected) { newItem.classList.add(IS_SELECTED_CLASS); }

Jahnp pushed a commit that referenced this issue Jul 20, 2017
* Dropdown: add IS_SELECTED_CLASS to option.selected (#331)

* fix tab

* fixed indenting

* lint fix, whitespace
@Jahnp
Copy link
Collaborator

Jahnp commented Jul 20, 2017

Closing this since #332 should have fixed the issue. Thanks @sevenam!

@Jahnp Jahnp closed this as completed Jul 20, 2017
@SSPO
Copy link

SSPO commented Jul 10, 2018

Find a work around when initializing Fabrics:

    var DropdownHTMLElements = document.querySelectorAll('.ms-Dropdown');
    for (var i = 0; i < DropdownHTMLElements.length; ++i) {
        var Dropdown = new fabric['Dropdown'](DropdownHTMLElements[i]);
        
        if(DropdownHTMLElements[i].querySelectorAll('option:checked').length==1){
            var selectedValue = DropdownHTMLElements[i].querySelectorAll('option:checked')[0].value
            $(DropdownHTMLElements[i]).find($('li:contains("'+selectedValue+'")')).addClass("is-selected")
            $(DropdownHTMLElements[i]).find($('.ms-Dropdown-title')).text(selectedValue);
        }
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants