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

Doing MVC with Baman.js

Zhusee
February 27, 2014

Doing MVC with Baman.js

A very brief intro to Batman.js as a Javascript MVC framework. (Chinese-English mixed)

Zhusee

February 27, 2014
Tweet

More Decks by Zhusee

Other Decks in Technology

Transcript

  1. Why Batman? ✓ CoffeeScript = 什麼都可以繼承 ✓ 跟 Rails 很容易整合

    (official gem) ✓ 語法邏輯跟 Rails 相似 (搭配上⼿手相對快) ✓ 很清楚什麼時候可以找 jQuery 進來搭配 ✓ iOS-like View 的概念很好⽤用
  2. gem “batman-rails”
 $ rails g batman:app $ rails g batman:scaffold

    todos 第一次安裝進 Rails 快速產生 Routing + Controller + Model + View
  3. Batman.View • iOS-like View Lifecycle • Easy to work with

    jQuery • 2-Way Data-Binding • Appending Subviews and DOM • View class Inheritance • Encapsulation with custom Views
  4. View Lifecycle (as events)! viewDidMoveToSuperview viewDidLoad ready viewWillAppear viewDidAppear Appending

    Subview viewWillRemoveFromSuperview viewWillDisappear viewDidDisappear Removing Subview 8KGY䥥⑈⺚ビ側ⓛ䛟⨉䡌橃⃫ ⛐⇆桬瘟䠉L3WGT[≧夶䛧&1/
  5. Batman.View • Find DOM root for View with this.node •

    Provide handlers for view event binding
  6. Custom View and Inheritance Every View is a CoffeeScript class,

    so you can inherit views by simply using extends
  7. Why Batman? ✓ CoffeeScript = 什麼都可以繼承 ✓ 跟 Rails 很容易整合

    (official gem) ✓ 語法邏輯跟 Rails 相似 (搭配上⼿手相對快) ✓ 很清楚什麼時候可以找 jQuery 進來搭配 ✓ iOS-like View 的概念很好⽤用