A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/peterlevel1/cc-mvc below:

peterlevel1/cc-mvc: for fe boys who still rely on jQuery, it is easy to use, and simpler than Backbone

for fe boys who still rely on jQuery

e.g.

<div id="JS_aside">
  <button data-role='add'>+</button>
  <button data-role='minus'>-</button>
  <span data-role=count></span>
</div>
import { Controller } from 'cc-mvc';

const controller = new Controller({
  init() {
    // organize the model and the viwe

    // 1. for triggering render work, give model to the view
    this.view.model = this.models.count;

    // 2. for convenience, give el to the model count
    this.models.count.el = this.view.el;

    // init render
    this.state.count = 0;
  },

  models: [{
    key: 'count',
    render(value) {
      this.el.find('[data-role=count]')
        .html(value);
    }
  }],

  view: {
    selector: '#JS_aside',

    events: {
      'click [data-role=add]': 'add',
      'click [data-role=minus]': 'minus',
    },

    methods: {
      add() {
        this.model.v = this.model.v + 1;
      },

      minus() {
        this.model.v = this.model.v - 1;
      }
    }
  }
});

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