Widget instances should have an event aggregator.
Signature is eventName and data.
Signature is eventName and callback that receives data from event trigger.
| // el - the element to be used to create the widget instance | |
| // name - the name to resolve to in the widget hash | |
| // options | |
| // - attributes - widget attributes | |
| // - success - call after widget has been instantiated and life cycle is complete | |
| // - error - call if there is an error during construction or life cycle | |
| <LazoView||LazoWidget>.prototype.createWidget = function (el, name, options) { | |
| // 1. el - update attributes, i.e., lazo-widget="name" | |
| // 2. resolve name to class in widget hash or use Class | |
| // if Class already exists throw error | |
| // 3. Construct instance; pull attributes from options; follow widget life cycle | |
| // 4. push instance to widget instances array | |
| // 5. call options.success(this) | |
| } |
Widget should be composable. Widgets should resolve to properties in the <instance>.widgets just as they do in views.
Widget afterRender and bind will happen from the top down.