Where communities thrive


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

    matthewp on master

    Update dist for release (compare)

  • 20:11

    matthewp on v6.2.0

    Update dist for release 6.2.0 (compare)

  • 20:05

    matthewp on master

    Fix bundlesize (compare)

  • 19:22

    matthewp on can-observable-bindings-1.3.0

    (compare)

  • 19:22

    matthewp on master

    fix(package): update can-observ… Set new bundle sizes Merge pull request #5389 from c… (compare)

  • 19:22
    matthewp closed #5389
  • 19:09
    matthewp commented #5389
  • 18:33

    matthewp on can-attribute-observable-2.0.1

    (compare)

  • 18:33

    matthewp on master

    fix(package): update can-attrib… Increase the bundlesize Merge pull request #5394 from c… (compare)

  • 18:33
    matthewp closed #5394
  • 17:59
    matthewp synchronize #5394
  • 17:59

    matthewp on can-attribute-observable-2.0.1

    Increase the bundlesize (compare)

  • 17:42
    matthewp synchronize #5389
  • 17:42

    matthewp on can-observable-bindings-1.3.0

    fix(package): update can-observ… Set new bundle sizes (compare)

  • 17:26
    greenkeeper[bot] labeled #5394
  • 17:26
    greenkeeper[bot] opened #5394
  • 17:26

    greenkeeper[bot] on can-attribute-observable-2.0.1

    fix(package): update can-attrib… (compare)

  • 17:15

    matthewp on can-stache-element-1.0.2

    (compare)

  • 17:15

    matthewp on master

    fix(package): update can-stache… Merge pull request #5387 from c… (compare)

  • 17:15
    matthewp closed #5387
Alexis Abril
@alexisabril
in this case, if it’s an empty array, .push would be akin to myMap.attr(‘users.0’, ‘123’);
however, if you did myMap.attr(‘users’, []), the setter would be called as you’d be setting the ‘users’ property directly
Justin Meyer
@justinbmeyer
yeah, the define plugin doesn't work for can.List unfortunately
Patrick Clancy
@patrickclancy
@alexisabril @justinbmeyer Thanks… I realized myMap.attr(‘users’, []) works. I was hoping that there was more magic there. ;-)
Alexis Abril
@alexisabril
it’d be cool if it works with can.List. For that scenario, it be nice to do:
var Collection = can.List.extend({
  define: {
    '*': {
      set: function(val) {
        console.log('setting');
        return val;
      }
    }
  }
});

var c = new Collection();
c.push('abc’);
Patrick Clancy
@patrickclancy
@alexisabril It would be nice. :sparkles:
Patrick Clancy
@patrickclancy

@daffl Do you know which version of phantomjs works with testee on the mac? I’ve installed 1.8.2 with homebrew and I’m still getting the timeout error. Testee works great in my other installed browsers. (safari, chrome…)

patrickclancy$ phantomjs —version -> 1.8.2

  status: 'failed',
  err: 
   { [Error: Browser timed out within 120 seconds]
     message: 'Browser timed out within 120 seconds',
     stack: 'Error: Browser timed out within 120 seconds\n    at testTimedOut [as _onTimeout] (/Users/patrickclancy/.nvm/v0.10.29/lib/node_modules/testee/lib/runner.js:43:42)\n    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)',
     title: 'http://localhost:3996/test/test.html?__token=hdh3gc on {"browser":"phantom"}' },
  title: 'http://localhost:3996/test/test.html?__token=hdh3gc on {"browser":"phantom"}' }
  1) http://localhost:3996/test/test.html?__token=hdh3gc on {"browser":"phantom"}
  testee:reporter updating run +0ms { status: 'finished',
  id: 'b87f411d-4fcd-47c3-9d30-2fe14dd7af0e',
  title: 'General error' }

  0 passing (2m)
  1 failing

  1) General error http://localhost:3996/test/test.html?__token=hdh3gc on {"browser":"phantom"}:
     Error: Browser timed out within 120 seconds
      at testTimedOut [as _onTimeout] (/Users/patrickclancy/.nvm/v0.10.29/lib/node_modules/testee/lib/runner.js:43:42)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Patrick Clancy
@patrickclancy
Is there a way to work wih radio buttons, can-value and true/false values? I seem to remember that using the define plugin and type: ‘htmlbool’ worked but I was wrong.
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