<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>select UI Component</title><link>https://community.telligent.com/community/11/w/api-documentation/67191/select-ui-component</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>select UI Component</title><link>https://community.telligent.com/community/11/w/api-documentation/67191/select-ui-component</link><pubDate>Tue, 19 Nov 2019 20:29:55 GMT</pubDate><guid isPermaLink="false">13d41401-f2aa-4b28-b079-2256b5585d77</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/api-documentation/67191/select-ui-component#comments</comments><description>Current Revision posted to API Documentation by Ben Tiedt on 11/19/2019 20:29:55&lt;br /&gt;
&lt;hr class="generated-documentation-start" style="border-width:0;" /&gt;&lt;h3&gt;&lt;a id="jQuery_telligent_evolution_ui_components_select" name="jQuery_telligent_evolution_ui_components_select"&gt;&lt;/a&gt;jQuery.telligent.evolution.ui.components.select&lt;/h3&gt;
&lt;p&gt;[[ui JavaScript API Module|UI Component]] which re-renders &lt;code&gt;select&lt;/code&gt; elements as [[glowDropDownList jQuery Plugin|glowDropDownList]] instances on desktop. On narrow devices, continues to render as a native select, to give the theme a chance to more preceisely theme the form field on desktop use. Re-rendered selects&amp;#39; values are still updated and available to interacted with.  [[ui JavaScript API Module|Overrides can be provided]] at the theme level to present &lt;code&gt;selects&lt;/code&gt; differently.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Example" name="Example"&gt;&lt;/a&gt;Example&lt;/h3&gt;
&lt;p&gt;Usage&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Re-renders the select as a glowDropDownList on the desktop, not on mobile
&amp;lt;select class=&amp;quot;ui-select&amp;quot; id=&amp;quot;mySelect&amp;quot;&amp;gt;
    &amp;lt;option value=&amp;quot;a&amp;quot;&amp;gt;Option A&amp;lt;/option&amp;gt;
    &amp;lt;option value=&amp;quot;b&amp;quot;&amp;gt;Option B&amp;lt;/option&amp;gt;
    &amp;lt;option value=&amp;quot;c&amp;quot;&amp;gt;Option C&amp;lt;/option&amp;gt;
    &amp;lt;option value=&amp;quot;d&amp;quot;&amp;gt;Option D&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;

// Returns the value of the select, even when re-rendered
var value = $(&amp;#39;#mySelect&amp;#39;).val();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A barebones UI component override which would result in not re-rendering &lt;code&gt;select&lt;/code&gt; elements&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.ui.components.select = {
    setup: function() { },
    add: function(elm, options) {
        // do nothing when added instead of re-rendering
    }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;&lt;a id="Default_Implementation" name="Default_Implementation"&gt;&lt;/a&gt;Default Implementation&lt;/h3&gt;
&lt;p&gt;For reference purposes or as the basis for an override:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(function($, global){

var minWindowWidth = 570,
    minWidth = 150,
    measuredHeight = null,
    measuredBorderHeight = null;

function measure(elm) {
    if(measuredHeight)
        return;
    var testDiv = $(&amp;#39;&amp;lt;span class=&amp;quot;uiselect&amp;quot;&amp;gt;&amp;lt;span&amp;gt;measure&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&amp;#39;).css({&amp;#39;display&amp;#39;:&amp;#39;none&amp;#39;}).appendTo(elm.parent());
    measuredHeight = testDiv.height();
    measuredBorderHeight = parseInt(testDiv.css(&amp;#39;border-top-width&amp;#39;) || &amp;#39;0&amp;#39;) + parseInt(testDiv.css(&amp;#39;border-bottom-width&amp;#39;) || &amp;#39;0&amp;#39;);
    testDiv.remove();
}

$.telligent.evolution.ui.components.select = {
    setup: function() { },
    add: function(elm, options) {
        elm.removeClass(&amp;#39;ui-select&amp;#39;);
        measure(elm);

        if(elm.is(&amp;#39;select&amp;#39;) &amp;amp;&amp;amp; $(window).width() &amp;gt; minWindowWidth) {
            // set the height of the expanded view to not have empty space
            var optionLength = elm.find(&amp;#39;option&amp;#39;).length;
            var expandedHeight = optionLength * measuredHeight;

            // set a reasonable default width
            var width = elm.width();
            if(width &amp;lt; minWidth)
                width = minWidth;

            // render
            elm.show().glowDropDownList({
                selectedItemWidth: width + 20,
                selectedItemHeight: measuredHeight,
                itemsWidth: width + 20,
                itemsHeight: expandedHeight + measuredBorderHeight + 4, // (glowDropDownList assumes to - 4 from height)
                buttonImageUrl: null,
                className: &amp;#39;uiselect&amp;#39;
            });
        }
    }
};

})(jQuery, window);
&lt;/code&gt;&lt;/pre&gt;

&lt;hr class="generated-documentation-end" style="border-width:0;" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>