Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Generic element controller. Binds an element to a controller.

License

Notifications You must be signed in to change notification settings

wethegit/wtc-controller-element

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElementController and ExecuteController

Install

$ npm install wtc-controller-element --save

ExecuteController

ExecuteController is a static class used to register and instanciate controllers extended from the ElementController class.

How to register a controller.

Inside your module, BEFORE exporting it:

// Register
ExecuteControllers.registerController(TestController, '[Name]');

As a convention, please use the name as the same name of the controller.

How to instanciate controllers.

There are 2 options, but first, import it:

import {ExecuteControllers}  from 'wtc-controller-element';
All at once

This will instanciate all elements with a [data-controller] attribute.

ExecuteControllers.instanciateAll();
Explicit

Just pass in the element and the name of the registered controller or the controller itself.

ExecuteControllers.instanciate(document.getElementById('id'), ['TestController'|TestController]);

ElementController

ElementController is the base class for controllers that alter DOM elements. It's responsible for saving the state and the instance of the controller for easy reference.

Usage

Import and extend it in your module.

import {default as ElementController, ExecuteControllers}  from 'wtc-controller-element';

class TestController extends ElementController {
  constructor(element) {
    super(element);
  }
}

/* Don't forget to register it */
ExecuteControllers.registerController(TestController, 'TestController');

bower

bower version is DEPRECATED and is here for older projects.
Please use the new ES6 module if possible.

Install

bower install wtc-controller-element

Usage

Simply extend it on your controller function.

About

Generic element controller. Binds an element to a controller.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published