websemantics / Image-Select

Image Select is an extension of Chosen, a jQuery plugin that makes long, unwieldy select boxes much more user-friendly. It provides image support for Single and Multi select HTML tags.
http://websemantics.github.io/Image-Select
MIT License
148 stars 44 forks source link

Problem with the selected value #40

Closed hamyo closed 7 years ago

hamyo commented 7 years ago

Good day. When I call trigger("chosen: updated") in a script, the selected value is displayed without an image.

<select id="example" class="img-select">
    <option data-img-src="images/1.png" value="1">1</option>
    <option data-img-src="images/2.png" value="2">2</option>
    <option data-img-src="images/3.png" value="3">3</option>
    <option data-img-src="images/4.png" value="4">4</option>
</select>

 <script type="text/javascript">
        $(document).ready(function () {
            let $example = $("#example");
            $example.chosen({disable_search: true});
            $example.find("option").first().hide();
            $example.find("option[value=3]").prop('selected', true);
            $example.trigger("chosen:updated");
            });
    </script>
websemantics commented 7 years ago

Should work now :)