JAVASCRIPT EXAMPLES Shared UI
On the surface of things, there may appear to be nothing terribly exceptional about this example. There is a slider widget that can control any of three selectable style properties: border width, padding, and font size. One way to achieve this effect would be to create one slider widget and write application logic that governs what the slider operates on, based upon the value selected in the select control. Of course, then you'd have to write your own code to update the configutation of this single slider widget when changing selection, since the value ranges for the different properties will differ. And if you later decided to offer the user a dedicated slider control for each style property, then your code would have to be significantly refactored. Instead, in this example there is a dedicated slider widget for each style property, but they all share the same DOM nodes in the document. Using the wireUi
and unwireUi
methods lets the code hand the slider DOM nodes back and forth between the different slider widgets, based upon the user's selection.