Giter Club home page Giter Club logo

reactive-rm's Introduction

reactive-rm

Plugin for reactive to conditionally remove (or reinsert) an element. Order is maintained.

Jump to: Usage - Example - Install - License

Build Status

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

<p data-remove="false">hey now</p>
<p data-remove="removeMe">hey now</p>
<p data-remove="{ name == 'hank'}">removed</p>
var reactive = require('reactive')
  , rm = require('reactive-rm')

var model = {
  name: 'hank',
  removeMe: function() { return false }
}

reactive(template, model, {
  bindings: {
    'data-remove': rm.binding
  }
})

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.

License

MIT © Vincent Weevers

reactive-rm's People

Contributors

vweevers avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.