Skip to content

Instantly share code, notes, and snippets.

@wclr
Created November 11, 2013 23:30
Show Gist options
  • Save wclr/7422552 to your computer and use it in GitHub Desktop.
Save wclr/7422552 to your computer and use it in GitHub Desktop.
can.Component({
tag: 'my-toggle',
template: '<button can-click="toggle">Toggle</button>',
scope: {
toggle: function(){
this.attr('shown', !this.shown)
}
}
})
can.Component({
tag: 'my-parent',
template: '<p>{{#props.visible}}Some thing{{/props.visible}}</p>' + '<my-toggle shown="props.visible"></my-toggle>',
scope: {
props: {
visible: true
},
name1: 'Alex'
},
helpers: {
name: function(){
return 'Some name'
}
},
events: {
'{scope.props} visible': function(scope, ev, visible){
slog('scope.visible change', visible)
}
}
})
$('body').append(can.view.mustache('<my-parent/>')())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment