<?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>Vacheslav Starikov&#039;s &#187; ajax</title>
	<atom:link href="http://starikovs.com/cat/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://starikovs.com</link>
	<description>BLOG</description>
	<lastBuildDate>Sun, 05 Sep 2010 18:05:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple ajax editing in CodeCharge Studio</title>
		<link>http://starikovs.com/2010/08/28/ajax-editing-ccs/</link>
		<comments>http://starikovs.com/2010/08/28/ajax-editing-ccs/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 07:54:09 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[codecharge]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=285</guid>
		<description><![CDATA[
How to implement an Ajax editing in CodeCharge Studio like in the picture above? Is it easy or not? Yes, it&#8217;s easy! It takes a half an hour at the maximum. In this article, I will provide step by step instructions. Also, you can download an example here. 
The main idea of this example is [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/ajax-editing-in-ccs.png" alt="Ajax editing in CCS" /><br />
How to implement an Ajax editing in CodeCharge Studio like in the picture above? Is it easy or not? Yes, it&#8217;s easy! It takes a half an hour at the maximum. In this article, I will provide step by step instructions. Also, you can download an example <a href="http://starikovs.com/my-examples/ccs-ajax-editing/NewProject3.zip">here</a>. </p>
<p>The main idea of this example is the ajax editing without the page refresh. When you click a link in the Grid the Show Modal dialog is opened. The Show Modal dialog contains a Record that allows to edit the data. All the actions are performed inside the Update Panels. Well, stay reading and you will see how to do it&#8230; <img src='http://starikovs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-285"></span></p>
<h3>Steps</h3>
<p><strong>1.</strong> I use <code>test</code> db and a table named <code>countries</code> in my localhost MySQL server.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #ff0000;">`test`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`countries`</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span>  <span style="color: #ff0000;">`test`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`countries`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`id`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`name`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">45</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>InnoDB <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">9</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1;</pre></div></div>

<p><strong>2.</strong> Add an UpdatePanel to the page and name it Panel1.</p>
<p><strong>3.</strong> Add a Grid to the Panel1. Grid should be created for the table <code>countries</code>. For the fields for Grid select only <code>name</code> field.</p>
<p><strong>4.</strong> After the Grid&#8217;s been created change the Label <code>name</code> to Link. Configure Href Source parameters for the Link. Add the <code>id</code> parameter with the SourceType of DataField and Parameter Source of <code>id</code> field. Leave the Link&#8217;s address empty. Also, add a Link for adding a new record. A new record Link should have no parameters and should remove the <code>id</code> parameter (Link->PW->Remove parameters->&#8221;id&#8221;).</p>
<p><strong>5.</strong> Add another UpdatePanel to the page and name it Panel2.</p>
<p><strong>6.</strong> Add ShowModal feature to Panel2 (Panel2->PW->Features->Add ShowModal). For the Show event select Panel1->countries->name->onclick and Panel1->countries->New->onclick. It makes ShowModal to be shown when Grid Row Link or Grid New Link is clicked.</p>
<p><strong>7.</strong> Add a new Record to a Panel2. A Record should be created on <code>countries</code> table and select only the <code>name</code> field.</p>
<p><strong>8.</strong> Add a Link to the end of the Panel2. This Link will hide the opened ShowModal. Also, go to Panel2->PW->Features->ShowModal and select for the Hide event this Link.</p>
<p><strong>9.</strong> Add this JavaScript to the end of the <code>&lt;head&gt;</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">/* This function should be called by links that open the ShowModal dialog. 
 * It sets a new href for the UpdatePanel according of clicked link 
 * and loads the data to the corresponding Record.
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> RelocatePanel2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">/* Panel2 is an UpdatePanel that contains a Record.
     * Also, Panel2 has a ShowModal feture.
     * Here, the location of the Panel2 is changed to have a new href 
     * with the id for Record.
     */</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Panel2&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">/* To load a new data to the Record according with the href that 
     * is set above, Panel2 should be reloaded. 
     */</span>
    AjaxPanel.<span style="color: #660066;">reload</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Panel2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>10.</strong> Again, add to the end of the <code>&lt;head&gt;</code> this style:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #00AA00;">&gt;</span>
<span style="color: #808080; font-style: italic;">/* This style makes Show Modal dialog wider. */</span>
body <span style="color: #6666ff;">.ModalShowDiv</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">350px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></div></div>

<p><strong>11.</strong> To the end of the Panel1 add this JavaScript:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #006600; font-style: italic;">/* RelocatePanel2() is added to the click event chain so it will be called
     * by all the record links in Grid. 
     * RelocatePanel2() sets a new href for the Record Update Panel and 
     * reloads the Record Update Panel.
     */</span>
    addEventHandler<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Panel1countriesname&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> RelocatePanel2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">/* Call RelocatePanel2() when a new link is clicked, too. */</span>
    addEventHandler<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Panel1countriesNew&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> RelocatePanel2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">/* RelocatePanel2() and Panel2ShowModal1_show() are in the 
     * click event chain so they are called one after another. 
     */</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>When the Panel1 is loaded the corresponding click events are set for the Links. The events should be binded on every refresh of an UpdatePanel and this is exactly what we do here.</p>
<p><strong>12.</strong> Add to the end of the Panel2 this JavaScript:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #009966; font-style: italic;">/* Reload the Grid Update Panel when some actions with Record are made. */</span>
    AjaxPanel.<span style="color: #660066;">reload</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Panel1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This JavaScript refreshes the Panel1 with the Grid to reflect the changes that made with the Record.</p>
<h3>Conclusion</h3>
<p>So, with help of CodeCharge Studio and a bit of coding of JavaScript and CSS the professional ajax applications can be created. For this example, I use a Grid and Record components and UpdatePanel and ShowModal fetures. Also, I use a bit of JavaScript and CSS coding. Now, it&#8217;s time to you to try something like this to create <img src='http://starikovs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Links</h3>
<p><a title="Rapid Web Application Development Tool" href="http://www.yessoftware.com/?2628" target="_blank">CodeCharge Studio</a></p>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2010/08/28/ajax-editing-ccs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to test for an empty javascript object</title>
		<link>http://starikovs.com/2010/03/10/test-for-empty-js-object/</link>
		<comments>http://starikovs.com/2010/03/10/test-for-empty-js-object/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 08:43:16 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=191</guid>
		<description><![CDATA[Hi everybody! I&#8217;ve just had a discussion of how to test for an emtpy javascript object. As a result, I have several code snippets and I want to share them with You.
Problem

alert&#40;&#123;&#125;==null&#41;; // false
alert&#40;&#123;&#125;==&#123;&#125;&#41;; // false
alert&#40;&#123;&#125;==&#123;&#125;&#41;; // false
alert&#40;&#123;&#125;==0&#41;; // false
alert&#40;&#123;&#125;==&#34;&#34;&#41;; // false
alert&#40;&#123;&#125;==&#91;&#93;&#41;; // false
// etc :)

So, none of the expressions above can check for an [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everybody! I&#8217;ve just had a discussion of how to test for an emtpy javascript object. As a result, I have several code snippets and I want to share them with You.</p>
<h3>Problem</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">==</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">==</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">==</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">==</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span>
<span style="color: #006600; font-style: italic;">// etc :)</span></pre></div></div>

<p>So, none of the expressions above can check for an empty javascript object. </p>
<p><span id="more-191"></span></p>
<h3>Pure javascript solution</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> empty<span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> o<span style="color: #009900;">&#41;</span> 
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>o.<span style="color: #660066;">hasOwnProperty</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<table>
<tr>
<th nowrap="nowrap" style="vertical-align:top;">object.hasOwnProperty(property)</th>
<td>Returns a boolean indicating whether the object has the specified property. This method does not check down the object&#8217;s prototype chain. </p>
<p>Learn details of <em>hasOwnProperty</em> <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object/hasOwnProperty" target="_blank">here</a> at developer.mozilla.org.</td>
</tr>
</table>
<h3>JQuery + JQuery.JSON solution</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> o <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">toJSON</span><span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'{}'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> o <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>a<span style="color: #339933;">:</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">toJSON</span><span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'{}'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span></pre></div></div>

<p>The code above simply converts an object to JSON string.</p>
<h3>Your way</h3>
<p>Well, if You have Your way of checking for an empty javascript object I am waiting Your comments! Thanks in advance!</p>
<h3>Links</h3>
<p><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object/hasOwnProperty" target="_blank">hasOwnProperty documentation</a></p>
<p><a href="http://jquery.com/" target="_blank">JQuery JavaScript Library</a></p>
<p><a href="http://code.google.com/p/jquery-json/" target="_blank">jquery-json plugin for JQuery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2010/03/10/test-for-empty-js-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline YUI AutoComplete layout</title>
		<link>http://starikovs.com/2009/11/04/inline-yui-autocomplete-layout/</link>
		<comments>http://starikovs.com/2009/11/04/inline-yui-autocomplete-layout/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 11:28:27 +0000</pubDate>
		<dc:creator>Vacheslav</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://starikovs.com/?p=71</guid>
		<description><![CDATA[ Recently, i had a problem with YUI AutoComplete layout. I wanted it being inline, fixed width and working with different browsers like IE6/7/8, Opera, FF etc. There were some problems that i solved primarily in CSS. More precisely, i needed an inline YUI AutoComplete layout in such a way that i can place autocomplete [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://starikovs.com/wp-content/uploads/2009/11/yuiautocompletelayout.PNG" alt="Inline YUI AutoComplete layout" title="Inline YUI AutoComplete layout" width="281" height="81" class="alignleft size-full wp-image-73" /> Recently, i had a problem with YUI AutoComplete layout. I wanted it being inline, fixed width and working with different browsers like IE6/7/8, Opera, FF etc. There were some problems that i solved primarily in CSS. More precisely, i needed an inline YUI AutoComplete layout in such a way that i can place autocomplete &lt;input&gt; next to the &lt;label&gt; without a line break. I just set my styles in CSS and override some existing styles and it works ok!</p>
<p><strong>So, problems i had to solve for my needs:</strong></p>
<ul>
<li>an outer container is a DIV so INPUT always goes on the next line</li>
<li>inline-block for DIV doesn&#8217;t work in IE6/7</li>
<li>an outer container has width of 100%</li>
<li>INPUT is absolutely positioned so an outer DIV is collapsed</li>
<li>width of 100% makes INPUT 6px larger then outer DIV in IE6</li>
<li>using inline-block, INPUT aligns vertically on the bottom in IE6</li>
</ul>
<p><span id="more-71"></span></p>
<h3>YUI files to include</h3>
<p>Let&#8217;s begin with files to include:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--CSS file (default YUI Sam Skin) --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/autocomplete/assets/skins/sam/autocomplete.css&quot;</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Dependencies --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/datasource/datasource-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Source file --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.8.0r4/build/autocomplete/autocomplete-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>Well, i&#8217;m explaining below how i&#8217;ve achieved an inline YUI AutoComplete layout. The code is well-commented to understand what is happening <img src='http://starikovs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>HTML</h3>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- </span>
<span style="color: #808080; font-style: italic;">Let's use SPAN becase it has &quot;display: inline&quot; by default.</span>
<span style="color: #808080; font-style: italic;">IE6/7 can apply &quot;display: inline-block&quot; only for elements</span>
<span style="color: #808080; font-style: italic;">that have &quot;display: inline&quot; by default.</span>
<span style="color: #808080; font-style: italic;">Read more: http://www.quirksmode.org/css/display.html.</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input&quot;</span>&gt;</span>YUI AutoComplete<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;autocomplete&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;results&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
/* creating a data source out of js array */
var ds = new YAHOO.util.LocalDataSource([&quot;apples&quot;, &quot;apricots&quot;, &quot;bananas&quot;]);
&nbsp;
/* creating a yui autocomplete */
var ac = new YAHOO.widget.AutoComplete(&quot;input&quot;, &quot;results&quot;, ds);
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<h3>CSS</h3>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* outer container */</span>
<span style="color: #cc00cc;">#autocomplete</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/* behaving like an inline element */</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> -moz-inline-box<span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for FF less then 3.0 */</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span> !important<span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
    <span style="color: #808080; font-style: italic;">/* standard width of a textbox */</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">145px</span><span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* align vertically on the center */</span>
    <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">middle</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* input */</span>
<span style="color: #cc00cc;">#autocomplete</span> input <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/* preventing an outer container DIV collapsing */</span> 
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
    <span style="color: #808080; font-style: italic;">/* tweaking to traditional box model
     * width = border + padding + content
     */</span>
    box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
    -moz-box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
    -webkit-box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
    -ms-box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* ie8 */</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* CSS Expression to calculate width for the input.
     * 2px border + 1px padding + 1px padding + 2px border = 6px.
     * Only for IE6/7 because traditional box model cannot
     * be tweaked by any css property.
     * currentStyle object - IE css styles as specified by 
     * global style sheets, inline styles, and HTML attributes.
     */</span>
    <span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> expression<span style="color: #00AA00;">&#40;</span>parseInt<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">this.parentNode.currentStyle.width</span><span style="color: #00AA00;">&#41;</span>-<span style="color: #cc66cc;">6</span><span style="color: #00AA00;">+</span><span style="color: #ff0000;">'px'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>I&#8217;ve tested this soluting in <strong>FireFox 3.5</strong>, <strong>Opera 10</strong>, <strong>IE 6/7/8</strong>. YUI version i&#8217;m using is <strong>2.8</strong>.</p>
<h3>Further reading:</h3>
<ul>
<li><a href="http://developer.yahoo.com/yui/autocomplete/" target="_blank">YUI 2 Autocomplete</a></li>
<li><a href="http://www.quirksmode.org/css/box.html" target="_blank">CSS Box Models</a></li>
<li><a href="http://www.quirksmode.org/css/display.html" target="_blank">Display declarations</a></li>
<li><a href="http://wiki.orbeon.com/forms/doc/contributor-guide/ie-bugs#TOC-Inline-block" target="_blank">inline-block in IE</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms535889(VS.85).aspx" target="_blank">IE runtimeStyle Object</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms528441(VS.85).aspx" target="_blank">IE currentStyle Object</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms535898(VS.85).aspx" target="_blank">IE style Object</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://starikovs.com/2009/11/04/inline-yui-autocomplete-layout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
