Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 07:26

    greenkeeper[bot] on webpack-cli-3.3.9

    (compare)

  • 07:18

    greenkeeper[bot] on webpack-cli-3.3.9

    chore(package): update webpack-… (compare)

  • 04:54
    justinbmeyer commented #5290
  • Sep 16 20:45
    matthewp commented #5291
  • Sep 16 20:44
    matthewp synchronize #5291
  • Sep 16 20:44

    matthewp on type8

    Increase bundlesize for core T… (compare)

  • Sep 16 20:30
    matthewp opened #5291
  • Sep 16 20:29

    matthewp on type8

    Upgrade to can-type 1.0.0-pre.8 (compare)

  • Sep 16 20:23
    phillipskevin labeled #5290
  • Sep 16 20:23
    phillipskevin labeled #5290
  • Sep 16 20:23
    phillipskevin opened #5290
  • Sep 16 19:56

    chasenlehara on major

    Bump can-connect version (compare)

  • Sep 16 18:12
    greenkeeper[bot] labeled #5289
  • Sep 16 18:12
    greenkeeper[bot] opened #5289
  • Sep 16 18:11

    greenkeeper[bot] on can-map-4.3.10

    fix(package): update can-map to… (compare)

  • Sep 16 17:51

    chasenlehara on major

    Update dependencies for 5.33.1 Update dist for release Merge branch 'master' into major (compare)

  • Sep 16 17:34

    chasenlehara on master

    Update dist for release (compare)

  • Sep 16 17:34

    chasenlehara on v5.33.1

    Update dist for release 5.33.1 (compare)

  • Sep 16 17:20
    greenkeeper[bot] closed #5285
  • Sep 16 17:20

    greenkeeper[bot] on can-stache-4.17.21

    (compare)

Alexis Abril
@alexisabril
@patrickclancy can-value can be set on a radio button, but I might be misunderstanding: http://jsbin.com/yexiji/2/edit?js,console,output
Patrick Clancy
@patrickclancy
@alexisabril Thanks for the jsbin example. In that example the isValid value on the map doesn’t effect/check the radio input. Clicking the radio input does set the value on the map. I realize that the map is using a boolean and the input value is a string. So I’d assume I’d need to configure this property with the define plugin. In the back corners of my mind I had a thought there was some sugar for working with this use case.
Patrick Clancy
@patrickclancy
@alexisabril Here’s what I was thinking would work. http://jsbin.com/neruda/10/edit
Adam L Barrett
@BigAB
Patrick Clancy
@patrickclancy
@BigAB Good to know... I hadn’t tried that. This time around the API I’m working with uses true/false.
dylanrtt
@dylanrtt
@patrickclancy Personally, I would do this with something at the view layer such as custom attributes so you don't have to litter your map definitions with knowledge of how they might be used in the view http://jsbin.com/zozuhevosa/2/edit?html,js,output
Patrick Clancy
@patrickclancy
@dylanrtt That’s cool! I like your idea of pulling it out of the model. ;-)
Alexis Abril
@alexisabril
@patrickclancy Ah, slightly updated version: http://jsbin.com/yexiji/3/edit
Adam L Barrett
@BigAB
@alexisabril that example logs true for both valid and invalid selections
Patrick Clancy
@patrickclancy
@alexisabril nice!! What do you think about @dylanrtt idea of making a custom attribute or componet?
Alexis Abril
@alexisabril
taking a quick peak just now
I like the abstraction
it’s basically a custom can-value
any reason checkboxes aren’t used for the boolean type instead of a radio button?
I know angular actually has filters for this type of stuff(turning a bool -> string, etc aside from the data layer and view)
Patrick Clancy
@patrickclancy
yea.. it’s nice when the map prop is on a model. The existing app uses this radio section convention.
Alexis Abril
@alexisabril
gotcha
yeah, in this case it’d be cool either way
if it gets really complex(re-structuring an object), I typically have a viewmodel inbetween the actual model and whatever is using it
and then put all my conversions in there
I’m starting to get drawn back to the filters approach though

then you could do:

<input type=“radio” can-value=“{foo}” can-type=“boolean”/>
<input can-value=“{modifiedAt}” can-type=“date”/>
<input can-value=“{price}” can-format=“$dd.dd”/>

or something

those syntaxes were off the top of my head, don’t hold me to those ;)
Patrick Clancy
@patrickclancy
ahh interesting…. "a viewmodel inbetween the actual model” I’ll need to think about how to implement that. I like the can-type=“…” you’ve really got me thinking about the possible ways to skin the model cat.
Alexis Abril
@alexisabril
heh, I feel like I did a can-currency-value a while back for this type of stuff
I just want a normalized way to do conversions between the presentation/data layer elegantly
Gerard Finnerty
@halcyonandon
@alexisabril arent mustache helpers appropriate to use when you want the view format to be different than the data format? That's what I use for currency, date, et al. ...unless I'm misunderstanding the original question
Matthew Phillips
@matthewp
A viewModel is for the view. I would put it there.
dylanrtt
@dylanrtt
@halcyonandon if you are only displaying the data, mustache helpers are certainly appropriate, but if the data is being manipulated in the view, then you can do a lot more with the viewModel such as add setters and type conversions through the define plugin that you wouldn't necessarily want in your model, or at least that is what I am understanding
Chris Gomez
@akagomez
Is there a way to get compute A’s value from within compute B without creating a binding? @justinbmeyer @alexisabril
computeA.value seems to work.
Sorry to bug you.
Ilya Fadeev
@ilyavf
hey guys, how can i define a computed property in a child component and setup a reference to it in its parent component?
Ilya Fadeev
@ilyavf
var ChildVM = can.Map.extend({
  define: {
    myComputed: {
        get: function(){ return 'foo';}
    }
  }
});
can.Component.extend({
    tag: 'my-child',
    viewmodel: ChildVM
});
can.Component.extend({
    tag: 'my-parent',
    template: can.stache('<my-child myComputed="{getComputed}"></my-child>')
    viewmodel: {
        getComputed: null
    }
});
Chris Gomez
@akagomez
I was wrong earlier. It’s computeA.computeInstance.value.
dylanrtt
@dylanrtt
@ilyavf you can access the parent scope from the child to set properties like in this example:
http://jsbin.com/zoginopiwu/2/edit?html,js,console,output
but there might be a better approach to your problem if you could provide more info
opolyo01
@opolyo01
hey guys, I am stuck with updating dimensionList attribute of ViewModel
var ViewModel = {
isSelectedDimension: '',
define: {
dimensionList: {
get: function() {
Here's the event that tries to update it
'.search-dimension keyup': function(el, ev){
var searchTerm = el.val();
var filteredDimensions = _.filter(this.scope.dimensionList(), function(dim){
return dim.title.indexOf(searchTerm) !== -1;
});
this.scope.attr('dimensionList', filteredDimensions);
},
somehow this.scope.dimensionList() always stays the same
I haven't worked with can.Components much, so might be missing something fundamental
Matthew Phillips
@matthewp
If you are using get then dimensionList is a compute. You can't replace it. You probably don't want a get in this case.
Chris Gomez
@akagomez
@opolyo01 Is this what you’re going for? http://jsbin.com/dagefe/1/edit?js,console
@matthewp We can replace computes on can.Map’s with { type: ‘compute’ }. It’s just not documented yet: bitovi/canjs#1690
opolyo01
@opolyo01
@akagomez Yes, I want something like this. Though, I am not sure I like this whole serialize thing. At first I can do -- map.attr('list') // [1, 2, 3] And after setting new array on the list I get a serialized object. Let me check that this will even auto update in my stache template if I keep serialized version of it
opolyo01
@opolyo01
@matthewp Ok so things with get should be immutable? But I thought the purpose of compute objects to be updated and bindable to a template. If I had a simple can.List outside of Map then everything would just work by updating the list, but what is the process of updating properties under can.Map within define?
Chris Gomez
@akagomez
@opolyo01 The serialize was for demonstration purposes only. Sorry to confuse.
@opolyo01 Here’s a better example: http://jsbin.com/dagefe/2/edit
Chris Gomez
@akagomez
@opolyo01 I think @matthewp Was misinterpretting your question. Computes are the low-level utility that backs can.Map.define. A compute takes a property on set… compute(newVal). So if you unknowingly attempted to set list to something else, like.. map.attr(‘list’, someOtherList), you’ll actually be passing someOtherList to the compute, like this.. map.list(someOtherList), as opposed to map.list = someOtherList. Does that make sense?