Skip to content

Instantly share code, notes, and snippets.

@PabloLefort
Created February 2, 2017 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PabloLefort/fb0e933886b886309d3e6ddc92caf145 to your computer and use it in GitHub Desktop.
Save PabloLefort/fb0e933886b886309d3e6ddc92caf145 to your computer and use it in GitHub Desktop.
Mithril change data in other components
var a = {
controller : function(){
var ctrl = this;
ctrl.data = m.prop(true);
ctrl.getData = function(){
ctrl.data = m.prop(!ctrl.data());
}
},
view: function(ctrl){
return m('div', [
m.component(b, {data: ctrl.data}),
m.component(c, {action: ctrl.getData})
])
}
}
var b = {
view: function(ctrl, args){
return m('h1', args.data())
}
}
var c = {
view: function(ctrl, args){
return m('a.btn', {onclick: args.action}, 'change')
}
}
@JessicaLawson
Copy link

Hello
Happy to meet you, my name is Miss Jessica Lawson, it is my pressure to meet you here  today through this site, i will like you to write to me so that i can be able to tell you more about me and the reason of my contact with you. here is my private email address, please write to me here so that i can tell you more anout me and also to send my picture  to you ( jesicalawson91@gmail.com )  thanks

Yours Miss Jessica Lawson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment