A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ripplejs/events below:

ripplejs/events: Listen for events like click, touch, etc in a template using attributes.

Listen for events like click, touch, etc in a template using attributes.

Install with component(1):

$ component install ripplejs/events

A template can use on-* to emit events on the view.

<button on-click="{{ this.save }}">Save</button>

This can be any type of event, eg: on-dblclick, on-touch, on-keydown. The node just needs to emit the event after the on- portion of the attribute.

var events = require('events');
var ripple = require('ripple');

// Compile the view
var View = ripple(template);

// Use the plugin
View.use(events);

// Listen for the events
View.prototype.save = function(){
  // Do things
};

You can also pass data to the directive and it will update automatically:

<button on-click="{{ this.save.bind(this, foobar) }}">Save</button>

or pass it through filters:

<button on-click="{{ this.save | preventDefault }}">Save</button>

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4