Ajax Blog


Protowidget: Widget system on top of Prototype

Posted in Ajax News by Dion Almaer on the May 31st, 2006

Terry Laurenzo found that he liked "the simplicity of Prototype, the widgets/templates from Dojo and the event-based property binding support from OpenLaszlo/Flex". This caused him to create Protowidget which builds on Prototype to add widget support a la Dojo.

Widgets

As the name implies, Protowidget is based on widgets. While some widgets are provided (and more will come in the future), Protowidget’s primary focus is on providing a rich environment for constructing complicated widgets.

A widget is always bound to an HTML element. This will typically be a div, but can really be anything (depending on the widget). We take the Dojo approach of leveraging custom attributes in order to do all of the wiring. This has the advantage of letting us bypass the ID-madness when it comes to hooking widgets to DOM elements. Here is an example:

<span pw.type='Text' pw.text='#{`[currentSection].model.title`}'></span>
 

This HTML declaration tells Protowidget to bind the span to the built-in Text widget. It further sets up a property binding so that the text property will be bound to the value of model.title on the current section (this example came from the Accordian title-bar template so the currentSection reference is an Accordian.SectionWidget in this context).

Protowidgets

Source: Ajaxian
Original Article: http://ajaxian.com/archives/protowidget-widget-system-on-top-of-prototype

Comments are closed.