$.jblocks({ // name: 'counter', // events: { // : b-inited, b-destroyed 'b-inited': 'oninit', // - 'click .js-inc': 'onClickPlus', 'click .js-dec': 'onClickMinus' }, // methods: { oninit: function() { this.$info = this.$node.find('.js-info'); this.count = 0; }, /** * */ onClickPlus: function() { this.inc(); this.update(); }, /** * */ onClickMinus: function() { this.dec(); this.update(); }, /** * */ inc: function() { this.count += this.params.step; }, /** * */ dec: function() { this.count -= this.params.step; }, /** * */ update: function() { this.$info.text(this.count); } } });
<div class="foo" data-b="ounter" data-p='{ "step": 2 }'> ... </div>
// $(document).jblocks('init'); // $(document).jblocks('destroy'); // DOM- $('#app').jblocks('init');
$('.foo').jblocks('get').each(function() { // this - , inc — this.inc(); });
Source: https://habr.com/ru/post/268109/
All Articles