These are chat archives for canjs/canjs

13th
May 2015
Gerard Finnerty
@halcyonandon
May 13 2015 17:55
hey, is there a way to define the value of an attr in the viewModel to the same as something else in the viewModel? like viewModel : { someVal: this.viewModel.someOtherVal } where someOtherVal
Justin Meyer
@justinbmeyer
May 13 2015 18:16
@halcyonandon with the define plugin, yes
but not sure why you would want to do that
define: {
  someVal: {
    get: function(){
      return this.attr("someOtherVal");
   }
  }
}
to make it read/write, you'd have to setup a setter too
Gerard Finnerty
@halcyonandon
May 13 2015 19:12
thanks... the reason (maybe there's a better way), an observable with a bunch of attrs gets passed through child components, one child displays, the other allows a field to update that value... the thing is, it shouldn't update those values until it passes validation and makes a successful api call... so in the edit component, I wanted to give it a can-value of something that gets pre-populated with the other value being observed elsewhere, then on successful update only I set the observed value
Marshall Thompson
@marshallswain
May 13 2015 19:14
The setValue arg might be what you’re looking for: http://canjs.com/docs/can.Map.prototype.define.set.html
largoelks
@largoelks
May 13 2015 21:11

I am trying to follow the docs describing the define plugin set function. Specifically the section on merging during the set().

"If you would rather have the new Map or List merged into the current value, not replaced, call attr inside the setter"
http://canjs.com/docs/can.Map.prototype.define.set.html

It seems for me the prop like this.info is undefined. Maybe the syntax has changed. :smile:
I made a jsbin - http://jsbin.com/hiyukiwuxu/4/edit

Marshall Thompson
@marshallswain
May 13 2015 21:22
@largoelks Well, that’s definitely broken. Do you mind making a GitHub issue for that?
largoelks
@largoelks
May 13 2015 21:23
@marshallswain - ok
Justin Meyer
@justinbmeyer
May 13 2015 21:32
@daffl bitovi/canjs#1693
I think this is a bug
need to fix this for place-my-order
largoelks
@largoelks
May 13 2015 21:38
@marshallswain Looks like it's already an issue. bitovi/canjs#1047
Marshall Thompson
@marshallswain
May 13 2015 21:39
Ahh. Thanks for checking on that first.