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
- Host: GitHub
- URL: https://github.com/gwendall/meteor-ui-hooks
- Owner: gwendall
- Created: 2015-04-29T13:53:06.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T14:16:56.000Z (almost 8 years ago)
- Last Synced: 2025-04-04T22:46:59.671Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 32
- Watchers: 5
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
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}}
```