Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save devdays/206c5ec8832a3cb81a9e to your computer and use it in GitHub Desktop.
Sample create function in widget
_create: function() {
// this.element -- a jQuery object of the element the widget was invoked on.
// this.options -- the merged options hash
// Cache references to collections the widget needs to access regularly
this.filterElems = this.element.children()
.addClass( "ui-widget-content " + this.options.className );
this.filterInput = $( "<input type='text'>" )
.insertBefore( this.element )
.wrap( "<div class='ui-widget-header " + this.options.className + "'>" );
// bind events on elements:
this._on( this.filterElems, {
mouseenter: "_hover",
mouseleave: "_hover"
// toggles ui-state-focus for you:
this._focusable( this.filterInput );
// _hoverable works for ui-state-hover, but we will do something slighty different in our hover
this._on( this.filterInput, {
"keyup": "filter"
this.timeout = false;
<!-- the result of this widget is -->
<div class="ui-widget-header myClass">
<input class="" type="text"/>
<div id="myFilterable"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment