| Start |
|---|
| A simple control: rating Let us build a simple control, a rating widget, intended to be used as: No fancy CSS for now; this would render as: Clicking on a number selects that rating; and clicking the "x" sets the rating to null. Key points:
Note 1: In order not to overcomplicate the implementation, the rating values are inserted in an array - the Note 2: With the exception of the And a necessary fiddle: https://jsfiddle.net/h81mgxma/ (opens new window) |
| A couple of complex controls: edit a full object A custom control does not have to limit itself to trivial things like primitives; it can edit more interesting things. Here we present two types of custom controls, one for editing persons and one for editing addresses. The address control is used to edit the person's address. An example of usage would be: The model for this example is deliberately simplistic: The address editor: Key points:
The code for the person custom control is almost identical. The template is using the Note: Here the objects are typed, i.e. they have proper constructors. This is not obligatory; the model can be plain JSON objects. In this case just use The fiddle: https://jsfiddle.net/3tzyqfko/2/ (opens new window) Two versions of the fiddle having extracted the common code of the controllers: https://jsfiddle.net/agj4cp0e/ (opens new window) and https://jsfiddle.net/ugb6Lw8b/ (opens new window) |
Read Article
https://develop.horje.com/learn/1434/reference