package
Basic DOM widget library for Ender
npm install widgetGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
This module is a very loose interpretation of the jQuery UI widget pattern for Ender, with the minimalist goals of Backbone's View object mixed in. Here are some of the features of the library:
There are some notable differences from the jQuery UI widget class:
Things that don't exist now, but may be added in the future:
After you install Ender, include widget in your package:
ender add widgetThere are two ways to create widgets. The first is to use the $.widget method, ala jQuery UI:
$.widget('MyNamespace.MyWidget', {
options: {
// Default options...
},
init: function () {
// Initialize widget
},
destroy: function () {
// Destroy the widget
this.__super__.destroy(); // Or: this._super('destroy')
}
}The alternative way is to just inherit directly from the $.Widget class. This makes the most sense if you are using, e.g., CoffeeScript:
class MyWidget extends $.Widget
options: {
# Default options
}
init: ->
# Initialize the widget
destroy: ->
# Destroy the widget
super()If you use the first method, your widget will be added to the $ object:
$.MyNamespace.MyWidget(options, el)
$(el).MyWidget(options)If you're using the second method, you'll need to instantiate the widget directly.