These are chat archives for canjs/canjs

26th
Aug 2015
Justin Meyer
@justinbmeyer
Aug 26 2015 14:33
@cherifGsoul please create an issue
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 26 2015 14:33
@justinbmeyer about can-connect?
Justin Meyer
@justinbmeyer
Aug 26 2015 14:34
yeah
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 26 2015 14:35
ok, even for can.Model backward it dosent work, I think is an issue the behavior mixin !!
dylanrtt
@dylanrtt
Aug 26 2015 18:10
Am I doing something wrong here? http://jsbin.com/vusuyaqolo/edit?html,js,output The parent and child templates are not updating...
Ilya Fadeev
@ilyavf
Aug 26 2015 18:51
hi. In define plugin, is lastSetValue always undefined for getter when setter is not used and .attr('prop', 'someval') not called? http://jsbin.com/kixoze/7/edit?js,console
Justin Meyer
@justinbmeyer
Aug 26 2015 18:52
@dylanrtt I'm not sure that you can pass viewModel values like that
dylanrtt
@dylanrtt
Aug 26 2015 18:54
Aren't reference values supposed to be 2-way bindable? That's the default behavior if no curly brackets are on it (same as single curlies).
Justin Meyer
@justinbmeyer
Aug 26 2015 18:56
$("#demo-html").viewModel({
  setParentAttr: function(vm) {
    vm.attr('parentAttr', 'def');
  }
});
I don't think you can set a method on a view model like that
best case, this would be like doing
vm = new can.Map();
vm.setParentAttr = function(vm) { ... }
but I think what it is actually doing is
vm.attr("setParentAttr", function(vm){ ... })
this is the problem w/ can-autorender ... you can't really make its viewModel a different type of can.Map
we've thought about a way to define what the viewModel type should be
but haven't found a great API for it
btw, could you try:
$("#demo-html").viewModel().setParentAttr = function(vm){ ... }
that might work
dylanrtt
@dylanrtt
Aug 26 2015 19:00
well that was just for illustration purposes and the function seemed to be running
Justin Meyer
@justinbmeyer
Aug 26 2015 19:00
ah, the function is running, but the wrong arguments?
dylanrtt
@dylanrtt
Aug 26 2015 19:01
maybe this is a better example http://jsbin.com/doxuvusiqo/edit?html,js,output
Justin Meyer
@justinbmeyer
Aug 26 2015 19:05
this is an interesting case
so {{parentAttr}} is bound to the "template scope"'s parentAttr property
later, when you set parentAttr, it's on the my-component viewModel
which is different then the template-scope
dylanrtt
@dylanrtt
Aug 26 2015 19:07
ah, that makes sense
Justin Meyer
@justinbmeyer
Aug 26 2015 19:07
this is why {{parentAttr}} doesn't change
well, that doesn't change
because once can.view.Scope finds a "context" that has a parentAttr value ... it stops listening for other contexts
technically, {{parentAttr}} should probably change to "def"
because viewModel.parentAttr should be higher then templateVM.parentAttr
but there's big performance advantageous for not listening to other scopes
once you found a match
I added parentAttr: null
dylanrtt
@dylanrtt
Aug 26 2015 19:11
I actually don't have a need for 2-way binding this way. So far, I've only needed to give the parent scope read access to the child, but I ran into a bug where the refs scope was modifying the child (after a routing change ended a batch) and the compute would throw an error. I was trying to see if I could reproduce it in a smaller case like this but it doesn't update the child as we are seeing.
Justin Meyer
@justinbmeyer
Aug 26 2015 19:11
also, you could do {{./parentAttr}}
ah
yeah, please let me know if you can reproduce
dylanrtt
@dylanrtt
Aug 26 2015 19:12
The weird thing is there was no reason for the parent scope to be modified as it was basically just inserting. Depending on how I got to the page, it would not happen at all