Skip to content
Adam Grant edited this page Sep 29, 2016 · 7 revisions

Mozart Guides

Click on the titles for full details

[Hello World](hello world)

<div data-component="hello_world"></div>

[Create ajax routing for a component](ajax routing)

<div data-component="number_collector">
  <input type="tel" />
  <button id="send">Send</button>
</div>

m$.number_collector.events = function(_$) {
  _$("#send").click(function() {
    _$.api.create({ number: _$("input").val(); });
  });
}

Set API after run

m$.mycomponent.events = function(_$) {
  _$("p").click(function() {
    _$.set_api({
      another_function: function(_$, options) {}
    });
  });
}

Pass backend variables to components

m$.store = {
  my_component: { users: @users }
}

m$.my_component.ready(function(_$) {
  _$.store.users.forEach(function(user) {
    // ...
  });
});
Clone this wiki locally