reactive-rm
Plugin for reactive to conditionally remove (or reinsert) an element. Order is maintained.
Usage
Add an attribute to the element: data-remove="expression"
, where expression
is either a:
- string boolean (
"true"
or"false"
) - model property name
- javascript expression (interpolated).
If thruthy, the element is removed. If falsy, the element is reinserted.
Regarding use together with the each
binding (on the same element): a mutating array will likely cause problems. Either let each
handle element removal (recommended) or use an immutable array.
Example
hey nowhey nowremoved
var reactive = rm = var model = name: 'hank' { return false }
Note, the standard method for loading plugins, view.use(plugin)
, will not work (currently). This is due to attributes being interpolated by reactive, after which the plugin can't subscribe to changes.
Install
npm i reactive-rm
Then use browserify to bundle for the browser.