CodeIgniter wrapper for YUI - CIwY 0.0.03 Beta


Autocomplete Widget

The Autocomplete widget provides functions that enable you to embed the YUI autocomplete widget in your page.

Initializing the Class

Like in CodeIgniter, the Autocomplete Widget is initialized in your controller using the $this->ciwy->loadComponent() function:

$this->ciwy->loadComponent('autocomplete');

Once loaded, the Autocomplete Widget is ready to be used in your wiev
echo $this->ciwy->yuiTags();
echo $this->ciwy->container('autocomplete');
echo $this->ciwy->generate();
If necessary you can change widget property using

Examples

Here is an example showing how you can create a autocomplete widget setting some properties.

$this->ciwy->loadComponent('autocomplete');
echo $this->ciwy->yuiTags();
echo $this->ciwy->container('autocomplete');
echo $this->ciwy->generate();

$this->ciwy->autocomplete->container();

Returns HTML code for the autocomplete container.

echo $this->ciwy->autocomplete->container();
// Produces: <div id="autocomplete"></div>

$this->ciwy->autocomplete->create_istance();

Create a new autocomplete widget istance and return its name.
The function accept as optional parameter the name of the new istance, if exists an istance with the same name, the function will first generate a new istance name for you and then the new istance itself.

$this->ciwy->autocomplete->create_istance('ac1');

$this->ciwy->autocomplete->generate();

Return HTML code with JavaScript inside

<script type="text/javascript">
  (function() {
    var Dom = YAHOO.util.Dom,
    Event = YAHOO.util.Event;
    var ds1 = new YAHOO.util.LocalDataSource(
      [
        "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Dakota", "North Carolina", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"
      ]
    );
    ds1.responseType = YAHOO.util.LocalDataSource.TYPE_JSARRAY;
    ds1.responseSchema = {
      fields : ["field"]
    };
    var ac1 = new YAHOO.widget.AutoComplete("ac1_input", "ac1Container", ds1);
  })();
</script>

$this->ciwy->autocomplete->setProperty();

Used to manually set YUI autocomplete widget property. The function will prevent to set invalid property name.

$property = array('useShadow' => true);
$this->ciwy->autocomplete->setProperty($property);