Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 20 08:05
    cduivis starred canjs/canjs
  • Nov 20 08:05
    cduivis starred canjs/canjs
  • Nov 16 08:54
    nullrooter starred canjs/canjs
  • Nov 12 18:48
    cherifGsoul synchronize #5509
  • Nov 12 18:48

    cherifGsoul on upgrade-can-ajax

    Upgrade ios version (compare)

  • Nov 06 17:32

    cherifGsoul on master

    Update dist for release (compare)

  • Nov 06 17:32

    cherifGsoul on v6.6.1

    Update dist for release 6.6.1 (compare)

  • Nov 06 17:26

    cherifGsoul on upgrade-can-param-can-deparam-661

    (compare)

  • Nov 06 17:25

    cherifGsoul on master

    Preapre v6.6.1 (#5512) (compare)

  • Nov 06 17:25
    cherifGsoul closed #5512
  • Nov 05 18:50
    cherifGsoul opened #5512
  • Nov 05 18:38

    cherifGsoul on upgrade-can-param-can-deparam-661

    Preapre v6.6.1 (compare)

  • Nov 05 18:30

    cherifGsoul on master

    Removed link on "enterprise com… (compare)

  • Nov 05 18:30
    cherifGsoul closed #5510
  • Nov 04 20:46
    cherifGsoul synchronize #5509
  • Nov 04 20:46

    cherifGsoul on upgrade-can-ajax

    Update appium version (compare)

  • Nov 04 19:22
    cherifGsoul synchronize #5509
  • Nov 04 19:22

    cherifGsoul on upgrade-can-ajax

    Update ios version (compare)

  • Nov 04 15:23
    themyshkin added as member
  • Nov 03 19:01
    justinbmeyer commented #5511
Frank Lemanschik
@frank-dspeed
your welcome
Nico R.
@nriesco
is there a way to trigger an action when a user modifies an <input> element, or when you clicke somewhere else (loose focus). Something like using enter as an event.
Kevin Phillips
@phillipskevin
not sure if you’re asking something more complicated, but this is how you trigger functions from dom events: http://canjs.com/doc/can-stache-bindings.event.html
Nico R.
@nriesco
looks like onfocusout is what I was looking for.. I’ll give it a try later
thanks @phillipskevin
Chasen Le Hara
@chasenlehara
@Lighttree Yeah, I would create types for the list and the maps, then you can use define for any properties that you need on either type (like the formatted values on the individual maps).
Since you’re on CanJS 2.x, you might want to check out can-validate-legacy if you haven’t seen it already: http://canjs.com/doc/can-validate-legacy.html
Rob Lao
@viewplatgh
canlist.extend({foo:() => { this.blahblah }}) not working with typescript, this would point to module rather than the object in context. Any ideas?
Could canjs team please take care of typescript a bit
Kevin Phillips
@phillipskevin
arrow functions don’t get a new context, so it will work like that in javascript also
canlist.extend({
    foo:() => {
        // `this` is the window
    },
    bar() {
        // `this` is the List instance
    }
})
thanks! using function() {...} works
Nico R.
@nriesco
@phillipskevin I forgot to remove the first two letters (‘on’) from the event name, now I’m using ($focusout)=".save(.)” and it works :-)
Kevin Phillips
@phillipskevin
:thumbsup: great @nriesco
Nico R.
@nriesco
is it possible to do this in can 2.x? this.attr(‘myAttr’, new MyObject({a:1,b:2})
and then in the .stache file use {{#with}} and access/edit the object properties?
Nico R.
@nriesco
I couldn't make it work using donejs
Nico R.
@nriesco
any ideas?
Kevin Phillips
@phillipskevin
@nriesco can you share a JSBin?
lmagarian
@lmagarian
I have a property on a superMap that needs to load via another API. I'm trying this but know it's not right. Any tips?
"possibleEvents": {
"value": [],
"get": function () {
return Event.getList({}).then( function ( eventList ) {
return eventList;
});
}
},
Nico R.
@nriesco
@phillipskevin this would be the closest to what I’m trying to do
Chasen Le Hara
@chasenlehara
@lmagarian You could assign eventList to another property in your view model, so possibleEvents is the promise and eventList is the array.
I personally like to follow this pattern of having one property be the promise: https://github.com/donejs/bitballs/blob/master/public/components/player/list/list.js#L64-L68
Then use the promise’s value in a template, or wherever else: https://github.com/donejs/bitballs/blob/master/public/components/player/list/list.stache#L19
lmagarian
@lmagarian
Thanks @chasenlehara
Chasen Le Hara
@chasenlehara
👍
Chasen Le Hara
@chasenlehara
@nriesco I think the Type is creating a new instance when you’re expecting it to be null.
Also, new Map() is not what you want, but just new Person(), right?
Here’s how I think I would approach what you’re doing: http://jsbin.com/taguluzeku/1/edit?html,js,output
lmagarian
@lmagarian
@chasenlehara will that make more than one API call if playersPromise.value is referenced in multiple places?
Nico R.
@nriesco
@chasenlehara thanks, it looks good and it works as I expected. I’ll try to modify my donejs project to see if I can reproduce what you did.
Chasen Le Hara
@chasenlehara
@lmagarian It shouldn’t; value is only run the first time to get the initial value.
Even if it were in a get, it would only run again if something observable changed, but there’s nothing observable in that function.
Let’s say you did need to make that API call again because the arguments changed. That might look something like:
    orderBy: {
        value: "name"
    },
    playersPromise: {
        get: function(){
            return Player.getList({orderBy: this.orderBy});
        }
    }
Nico R.
@nriesco
@chasenlehara it does work in http://jsbin.com/taguluzeku/1/edit?html,js,console,output but when including it into my donejs project it will create the instance and even with default values, but if you modify any of the properties then it will “reset” the object (the if condition is met):
type: function(newPerson) {
  if (newPerson && newPerson instanceof Person === false) {
    console.log('>>> debug data 1:', newPerson);
    return new Person(newPerson);
  }
  return newPerson;
}
the problem after doing some debug is that the newPerson is the value of the input field, so it will never have any valid data again (as it is just one plain value)
I thought newPerson would at least be an object but only the currently selected input value is passed as newPerson
could it be can 2.x that is causing this?
Kevin Phillips
@phillipskevin
{($value)}=“newPerson” is binding the value of the <input> with newPerson, right?
Nico R.
@nriesco
@phillipskevin I made a mistake this is the JSbin: http://jsbin.com/kelilib/1/edit?html,js,output
the approach used by @chasenlehara works
but when I use it within the donejs project it won't
the way I use it looks like the jsbin (the last one) so you can set each of the properties
whenever you modify any of the inputs that are binded to a property of this new object then every input field is set with the return new Person(newPerson) code
and newPerson contains whatever you wrote on one of the inputs