Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/mithril/0.2.0/mithril.js"></script>
</head>
<body>
</body>
</html>
 
class ClickCounter
  constructor: ->
    @value = 0
class Parent
  constructor: (@counter) ->
    # Pass the model to the children
    @childA = new ChildA(@counter)
    @childB = new ChildB(@counter)
    
  view: => [
    @childA.view()
    @childB.view()
  ]
class ChildA
  constructor: (@counter) ->
    
  click: => @counter.value++
  view: => m('button', { onclick: @click }, "Click me")
class ChildB
  constructor: (@counter) ->
    
  view: => m 'div', "Button clicked " + @counter.value + ' times'
# Create the Parent with a model
m.mount document.body, new Parent(new ClickCounter)
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
pelonpelonpro
0viewers