public
Description: PURE Unobtrusive Rendering Engine for HTML
Home | Edit | New

The + notation to append/prepend values

By default a directive will replace the selected element node or attribute value.
Sometimes we want to keep the current value and append or prepend the result of the directive.

This is particularly useful if a directive needs to act on classes while auto-rendering.
As the class is used to map the HTML and the JSON, we may not want to replace the current value.

Append / Prepend notation

The + symbol before or after the selector string indicates if we want to append or prepend the value.

  • ‘tbody tr[class]’: rowDecorator
    Will replace the attribute class of the TR by the value returned by the function rowDecorator
     
  • ‘tbody tr[class]+’: rowDecorator
    Will append the current value of the class attribute of the TR by the value returned by the function rowDecorator
     
  • ‘+tbody tr[class]’: rowDecorator
    Will prepend the current value of the class attribute of the TR by the value returned by the function rowDecorator
     

Have a look at the example Attach Events to your HTML
The line with 'tbody tr[class]+' is an example that will append the result of the function to the class attribute but not replace it.

Last edited by pure, Tue Sep 16 03:45:33 -0700 2008
Home | Edit | New
Versions: