Sha256: d095952eea1a44b3e9ce852bca047eb0e0eac7d270f640eb6c88d147c59656e3

Contents?: true

Size: 719 Bytes

Versions: 7

Compression:

Stored size: 719 Bytes

Contents

function Counter(data) {
  this.value = data.value;
}

Counter.prototype.plus = function() {
  this.value++;
};

Counter.prototype.minus = function() {
  this.value--;
};

Counter.prototype.renderServer = function() {
  return '<div class="counter"><span id="value">' + this.value + '</span><button id="minus">-</button><button id="plus">+</button></div>';
};

Counter.prototype.updateValue = function(id) {
  $('#' + id + ' #value').text(this.value);
};

Counter.prototype.setUpHandlers = function (id) {
  var self = this;
  $('#' + id + ' #minus').click(function(e) {
    self.minus();
    self.updateValue(id);
  });

  $('#' + id + ' #plus').click(function(e) {
    self.plus();
    self.updateValue(id);
  });
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
js_render-0.7.0 examples/vanilla_js/app/assets/javascripts/components/Counter/index.js
js_render-0.6.0 examples/vanilla_js/app/assets/javascripts/components/Counter/index.js
js_render-0.5.0 examples/vanilla_js/app/assets/javascripts/components/Counter/index.js
js_render-0.4.0 examples/vanilla_js/app/assets/javascripts/components/Counter/index.js
js_render-0.3.0 examples/vanilla_js/app/assets/javascripts/components/Counter/index.js
js_render-0.2.0 examples/vanilla_js/app/assets/javascripts/components/Counter/index.js
js_render-0.1.1 examples/vanilla_js/app/assets/javascripts/components/Counter/index.js