<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Steve Peart &#187; Dojo Toolkit</title>
	<atom:link href="http://stevepeart.com/category/code/dojo/feed/" rel="self" type="application/rss+xml" />
	<link>http://stevepeart.com</link>
	<description>Internet Rambling, Life, Code</description>
	<lastBuildDate>Sun, 25 Apr 2010 04:28:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Dojo Form Widgets &#8211; dijit.form.FilteringSelect</title>
		<link>http://stevepeart.com/2009/04/dojo-form-widgets-dijitformfilteringselect/</link>
		<comments>http://stevepeart.com/2009/04/dojo-form-widgets-dijitformfilteringselect/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 19:21:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Dojo Toolkit]]></category>

		<guid isPermaLink="false">http://stevepeart.com/?p=9</guid>
		<description><![CDATA[Recently I wrote in some functionality that used the dijit.form.FilteringSelect widget from the dojotoolkit and had a special use-case, not discussed in the documentation. EDIT: Use dijit.byId(&#8216;myFilteringSelect&#8217;).attr(&#8216;displayedValue&#8217;); Instead, the rest can stay for historical purposes (assuming there would be any). Let&#8217;s say you have a basic FilteringSelect widget. Look at the example below: &#60;select id=&#34;myFilteringSelect&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wrote in some functionality that used the <a href="http://docs.dojocampus.org/dijit/form/FilteringSelect">dijit.form.FilteringSelect</a> widget from the <a href="http://dojotoolkit.org">dojotoolkit</a> and had a special use-case, not discussed in the documentation.</p>
<p><span style="color: #ff0000;">EDIT: Use dijit.byId(&#8216;myFilteringSelect&#8217;).attr(&#8216;displayedValue&#8217;); Instead, the rest can stay for historical purposes (assuming there would be any).</span></p>
<p>Let&#8217;s say you have a basic FilteringSelect widget. Look at the example below:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;select id=&quot;myFilteringSelect&quot; name=&quot;myOptions&quot;&gt;
   &lt;option value=&quot;1&quot;&gt;Something&lt;/option&gt;
&lt;/select&gt;</pre></div></div>

<p>If you want to grab the current value of a widget, it&#8217;s simple:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> currentSelection <span style="color: #339933;">=</span> dijit.<span style="color: #660066;">byId</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myFilteringSelect'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Current Selection: '</span> <span style="color: #339933;">+</span> currentSelection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Outputs 'Current Selection: 1'</span></pre></div></div>

<p>What if for some reason, you want the <strong>Displayed</strong> value of the widget? What this whole post is for:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> currentSelection <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">byId</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myFilteringSelect'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Current Selection: '</span> <span style="color: #339933;">+</span> currentSelection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Outputs 'Current Selection: Something'</span></pre></div></div>

<p>See the difference? We used dojo.byId instead of dijit.byId. When using the FilteringSelect widget, the place where the current option value is stored is within the widget, but dojo creates an underlying form input on the page with the id you gave your widget, and pops the display value there, the value you see in the box once you&#8217;ve selected something. So by simply using normal javascript to select it&#8217;s value via .value, we can grab that for use.</p>
<p>Not in the docs for FilteringSelect, and maybe there&#8217;s other issues with your code if you find yourself here, but for me, i needed the word, not the number, and had no control over how the html select was created. So there you go.</p>
]]></content:encoded>
			<wfw:commentRss>http://stevepeart.com/2009/04/dojo-form-widgets-dijitformfilteringselect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
