GithubHelp home page GithubHelp logo

isabella232 / fruitmachine-ftdomdelegate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ftlabs/fruitmachine-ftdomdelegate

0.0 0.0 0.0 69 KB

An ftdomdelegate plugin for FruitMachine

Home Page: http://labs.ft.com

License: MIT License

JavaScript 96.96% HTML 3.04%

fruitmachine-ftdomdelegate's Introduction

fruitmachine-ftdomdelegate Build Status

A ftdomdelegate FruitMachine helper.

This helper:

  • Instantiates the dom-delegate when a fruitmachine module is instantiated;
  • Binds that dom-delegate to the module's El when the fruitmachine module is setup;
  • Unbinds the dom-delegate instance from the El when the fruitmachine module fires its teardown event;
  • And destroys the dom-delegate when the fruitmachine module is destroyed.

Usage examples

var Apple = fruitmachine.define({
  name: 'apple',
  helpers: [require('fruitmachine-ftdomdelegate')],
  initialize: function() {
    this.onButtonClick = this.onButtonClick.bind(this);
  },
  setup: function() {
    this.delegate.on('click', 'button', this.onButtonClick);
  },
  onButtonClick: function() {
    this.fire('buttonclick');
  }
});

Note: as long as you properly destroy your fruitmachine modules after you're finished with them, you need not worry about detached DOM nodes because dom-delegate will ensure any event listeners added are removed when destroy is called on it.

Demonstration 'todo' app

There is a rework of the TODO example from the main fruitmachine project.

The modules that make use of the fruitmachine-ftdomdelegate helper are located here and here.

Installation

$ npm install fruitmachine-ftdomdelegate

Tests

$ npm install
$ npm test

Credits and collaboration

The lead developer of fruitmachine-ftdomdelegate is @matthew-andrews at FT Labs. All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request.

fruitmachine-ftdomdelegate's People

Contributors

apaleslimghost avatar kornelski avatar matthew-andrews avatar orangemug avatar rowanbeentje avatar wheresrhys 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.