These are chat archives for canjs/canjs

5th
Aug 2018
Dovid Bleier
@dbleier
Aug 05 2018 14:37
Hi all, using Can3, I have a custom component that I have injected into the stache and for some reason I can not fathom, the bindings aren't working.
    <can-import  from="./html-widget/" />
    <html-widget markup:from="html.markup" externals:from="html.externals" 
        code:from="html.code" ></html-widget>
    {{html.markup}}
the {{html.markup}} at the end was just to verify that the prop is visible in the stache
and the component itself is being rendered as I see the static text that is in the component
just the bindings are not being called.
Here is the code for the component itself, you'll see that I created at setter to console.log the value, but it never gets called
import Component from 'can-component';
import DefineMap from 'can-define/map/';
import './html-widget.less!';
import view from './html-widget.stache!';
import services from 'menuboard-manager/config/services/';
import $ from 'jquery';

export const ViewModel = DefineMap.extend({
    logger: {
        get() {
            return services.getService('logger');
        },
    },
    markup: {
        type: 'string',
        set(nv) {
            console.log('*********** MARKUP: ' + nv);
            return nv;
        }
    },
    code: 'string',
    externals: '*',

    createScriptTag(src) {
   ...
    },

    loadCode() {
    ..
    }
});

export default Component.extend({
    tag: 'html-widget',
    ViewModel: ViewModel,
    view: view,
    events: {
        "inserted": function() {
            this.viewModel.loadCode();
        }
    }
});