An open API service indexing awesome lists of open source software.

https://github.com/gwendall/meteor-ui-hooks

A simpler API for Blaze UI hooks
https://github.com/gwendall/meteor-ui-hooks

Last synced: about 2 months ago
JSON representation

A simpler API for Blaze UI hooks

Awesome Lists containing this project

README

        

```diff
- NOTE: This package is not maintained anymore.
- If you want to help, please reach out to [email protected]
```

Meteor UI Hooks
===============

A simpler API for Blaze \_uihooks

Installation
------------

``` sh
meteor add gwendall:ui-hooks
```

Methods
----------

**Template[tplName].uihooks(hooks)**
Set the insert, move, remove as you would do with vanilla \_uihooks. Optionally pass the container of the items you want to look at (recommended).

Example
-------

``` javascript

Template.layout.uihooks({
'.item': {
container: '.container',
insert: function(node, next, tpl) {
console.log('Inserting an item.');
$(node).insertBefore(next);
},
move: function(node, next, tpl) {
console.log('Moving an item.');
},
remove: function(node, tpl) {
console.log('Removing an item.');
$(node).remove();
}
}
});
```

This is it. With this much simpler syntax, you can now play with UI hooks as you would do traditionally.
Some more code for the complete example, should you need it.

``` javascript
Items = new Mongo.Collection('items');
Items.insert({ title: 'foo' });

Template.layout.helpers({
items: function() {
return Items.find();
}
});

```

``` html


{{#each items}}
{{title}}

{{/each}}

```