These are chat archives for canjs/canjs

25th
May 2018
Chasen Le Hara
@chasenlehara
May 25 2018 00:09
I think you’d get the same warning, because required is still undefined (you’re referencing something that isn’t in your view-model).
I’d always have the property defined in your view-model.
Gregg Roemhildt
@roemhildtg
May 25 2018 13:58
What's the best way I use a promise in canjs that happens to be sealed? A library I'm working with is returning a sealed promise and Canjs tries to define an additional property and it errors out.
Gregg Roemhildt
@roemhildtg
May 25 2018 14:06
I think this works: Promise.resolve(otherPromise); but I was wondering if there's a better way
Chasen Le Hara
@chasenlehara
May 25 2018 15:25
@roemhildtg That might be your best bet… which CanJS package is adding properties to the promise?
Gregg Roemhildt
@roemhildtg
May 25 2018 17:38
I think it happens in can-stache and can-reflect. It adds some _observeData or something like that so promise.isPending...etc work
Promise.resolve wrapper is working fine, so I'll stick with that
Got another one for ya if you have a sec.
Using event delegation in a component, how can I access the underlying data?
export default Component.extend({
    tag: 'dl-feature-table',
    ViewModel,
    view,
    events: {
        'tbody tr mouseover': function() {
            // need to access the row's view model object here
            debugger;
        },
    },
});
Gregg Roemhildt
@roemhildtg
May 25 2018 18:16
So basically, I just want to find the id number of the row that was clicked. Is there a good way to store that value in the row somehow?
Chasen Le Hara
@chasenlehara
May 25 2018 18:31
Yes, can-dom-data will be your friend: https://canjs.com/doc/can-dom-data.html
Gregg Roemhildt
@roemhildtg
May 25 2018 18:35
Nice!
That's exactly what I needed
Gregg Roemhildt
@roemhildtg
May 25 2018 18:42
Are there any additional imports for this to work? Not seeing the data get set and warnings:
sp-toast-container.js:16 can-stache/expressions/lookup.js: Unable to find key "@domData".
<tr {{domData('object', object)}} ...> should do it right?
Chasen Le Hara
@chasenlehara
May 25 2018 18:45
It should just be available in can-stache 4.3 https://github.com/canjs/can-stache/releases/tag/v4.3.0
Gregg Roemhildt
@roemhildtg
May 25 2018 18:49
Ah. Didn't realize that was new :/
Chasen Le Hara
@chasenlehara
May 25 2018 18:49
In CanJS 3 (and 2?) the {{data}} helper did the same thing
I’m not sure if {{data}} worked in can-stache 4.0/4.1/4.2; it might, I can’t remember.
If it’s a project with CanJS 3, then can-util/dom/data/ was the equivalent of the new can-dom-data: https://v3.canjs.com/doc/can-util/dom/data/data.html
Chasen Le Hara
@chasenlehara
May 25 2018 21:30
@roemhildtg Did you get it working in your project?