Upgrade to Pro — share decks privately, control downloads, hide ads and more …

5分でわかるMarionette.jsのいいところ

koba04
July 11, 2014

 5分でわかるMarionette.jsのいいところ

天下一クライアントサイドJS MV*フレームワーク武道会 (2014/07/11)のLTの資料です。

koba04

July 11, 2014
Tweet

More Decks by koba04

Other Decks in Programming

Transcript

  1. 4VQQPSU/FTUFE7JFX w #BDLCPOFKT͚ͩͩͱࣗ෼Ͱ7JFXͷ࡟আ WJFXSFNPWF Λ͢Δඞ ཁ͕͋Δ w .BSJPOFUUFKTͰ͸3FHJPOͱ3FHJPO.BOBHFS "QQMJDBUJPOͱ -BZPVU7JFX͕͍࣋ͬͯΔ

    ͕7JFXͷ੾Γସ͑࣌ͷॾʑΛ΍ͬͯ͘ ΕΔ var app = new Marionette.Application();! app.addRegions({ main: "#main" });! ! # render()͢Δඞཁ͸ͳ͍!!! app.main.show(new MyView());! app.main.show(new MyOtherView()); ˠ;PNCJF7JFX͕࡞ΒΕʹ͍͘
  2. 7JFX.BOBHFNFOU var TopView = Backbone.Marionette.LayoutView.extend({! template: template,! regions: {! artistSearch:

    “.js-artist-search",! topTracks: “.js-top-tracks"! },! onRender: function() {! this.artistSearch.show(! ! ! new ArtistSearchView(model: new Artist())! );! ! this.listenTo(tracks, 'reset', this.showTracks);! },! showTracks: function() {! this.topTracks.show(! new TracksView(collection: tracks)! );! }! });! ! ɿ! ɿ! App.content.show(new TopView());! RegionΛఆٛ ೖྗΤϦΞΛදࣔ collection͕reset͞ΕͨΒ ۂҰཡͷCollectionViewΛ දࣔ ApplicationͷRegionʹදࣔ