These are chat archives for canjs/canjs

2nd
Sep 2016
Christopher Oliphant
@RALifeCoach
Sep 02 2016 00:13
The methods need to be static or defined in the component events
Christopher Oliphant
@RALifeCoach
Sep 02 2016 00:36
Nope - you’re right - it doesn’t work
Christopher Oliphant
@RALifeCoach
Sep 02 2016 12:40
I am now trying the following:
const X = DefineMap.extend({
    y: {
        type: ‘string’,
        value: ‘yyyy’
    },
    onClickY: function () {
        console.log(‘click y’);
    }
});

const A = X.extend({
    b: {
        type: ‘string’,
        value: ‘bbbbbb’
    },
    onClickB: function () {
        console.log(‘click b’);
    }
});

Component.extend({
    tag: ‘x-a’,
    template: …
    ViewModel: A
});
Both ClickY and ClickB work, but the field y is given a warning - undefined - in the stache template
Christopher Oliphant
@RALifeCoach
Sep 02 2016 12:49
is there a JSBin already setup for canjs 3.0?
Christopher Oliphant
@RALifeCoach
Sep 02 2016 13:20
When I upgrade to the latest can-define - the above gives an error “Cannot redefine property: _data"
upgrade again
I just pushed a fix for that
Christopher Oliphant
@RALifeCoach
Sep 02 2016 13:57
thanks
portfolio-systems
@portfolio-systems
Sep 02 2016 14:50

Is it possible to 2-way bind a checkbox to a named attribute such that it just works (no additional JS) and if so how ??

Compare and contrast :

CHECKBOX
{{#each choices}}
<nput type=“checkbox” name=“cb1” value=“{{.}}” some-magic-binding/>
{{/each}}

SELECT
<select name=“select1” multiple {($value)}=“answer”>
{{#each choices}}
<option value=“{{.}}”>{{.}}</option>
{{/each}}
</select>

with this data
{
choices: [1,2,3,4,5],
answer: ‘2;4'
}

Select works out of the box but checkbox does not despite trying every variant of some-magic-binding known to man.

The best I can do is to use {($checked)}=“checked” as the some-magic-binding. This works but I have to run a js routine to init the checked attributes at page load time.

Seems like a major hack but I can’t find any other way.

Surely the whole point of live binding is to avoid this sort of explicit intervention. It would be REALLY good if checkboxes behaved like multiple selects.

What am I missing ??

Kevin Phillips
@phillipskevin
Sep 02 2016 14:53
in 2.3, you do need some additional js
you can take a look at the checkbox.stache and checkbox.js files here: https://gist.github.com/phillipskevin/a5892f9f1cf9a4d4ce936beb9080e615
we’re adding converter functions in 3.0 to make this much easier
but that’s the best way I’ve found to do it in 2.3
Justin Meyer
@justinbmeyer
Sep 02 2016 15:39
contributors meeting about to start: https://www.youtube.com/watch?v=yMYpSEjyr3I
Peter Hansen
@peter9477_twitter
Sep 02 2016 20:19
I'm trying to troubleshoot an issue which triggers a traceback in can/view/scope/compute_data's off() function, "TypeError: readInfo.teardown is not a function (readInfo.teardown is undefined)". It appears to be a race condition of some kind, as it's not 100% reproducible yet is easily repeatable every few attempts in the environments where it does happen. It looks like it's triggered by updating a 250-item array in my Model (replacing the data with new data, whether a new list or empty one), and it kills my view which is bound to this data (using a stache template). I'm likely going to have to shrink the app down to a much smaller example, but was wondering if anyone had suggestions to guide me on this. I'm unfamiliar with the CanJS code so my investigation is starting from scratch. (My own background: extremely experienced developer in general, fairly experienced in JavaScript as a language, still learning CanJS and associated "modern" JS libraries and tools.) Using CanJS 2.3.25 with jQuery 3.1.0, failure occurring mostly in iPhone 9.0 simulator in a Cordova app (i.e. in Mobile Safari using AppleWebKit 601.1.46) but has occurred elsewhere at times.
Hitesh Ubharani
@blackmamba
Sep 02 2016 22:13
@justinbmeyer there?