Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:04
    greenkeeper[bot] commented #5392
  • 01:04

    greenkeeper[bot] on core-js-3.5.0

    chore(package): update core-js … (compare)

  • Dec 11 18:34
    greenkeeper[bot] labeled #5444
  • Dec 11 18:34
    greenkeeper[bot] opened #5444
  • Dec 11 18:34

    greenkeeper[bot] on can-observable-mixin-1.0.7

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

  • Dec 11 18:30

    cherifGsoul on update-infrastructure-page

    (compare)

  • Dec 11 18:30

    cherifGsoul on master

    Update infrastructure page with… (compare)

  • Dec 11 18:30
    cherifGsoul closed #5441
  • Dec 11 18:30
    cherifGsoul closed #5417
  • Dec 10 17:40
    cherifGsoul review_requested #5443
  • Dec 10 16:47
    cherifGsoul review_requested #5441
  • Dec 10 16:35
    cherifGsoul synchronize #5441
  • Dec 10 16:35

    cherifGsoul on update-infrastructure-page

    Fix typos (compare)

  • Dec 10 10:01
    jkeruzec starred canjs/canjs
  • Dec 09 18:59
    cherifGsoul review_requested #5443
  • Dec 09 18:59
    cherifGsoul opened #5443
  • Dec 09 18:51

    cherifGsoul on document-inserted-removed-can6

    Add inserted/removed events to … (compare)

  • Dec 09 15:38
    greenkeeper[bot] labeled #5442
  • Dec 09 15:38
    greenkeeper[bot] opened #5442
  • Dec 09 15:38

    greenkeeper[bot] on can-view-live-5.0.1

    fix(package): update can-view-l… (compare)

Mohamed Cherif Bouchelaghem
@cherifGsoul
:/
Christopher Oliphant
@RALifeCoach

okay - I have a component:

<feature-icon type="article" types="articles" 
                                  isActive="{{isActive}}" 
                                  hasMedia="{{hasMediaContent('articles')}}" 
                                  profilesURL="options.profilesURL"></feature-icon>

with the component defined as:

    var Model = can.Map.extend({
        define: {
            hasMedia: {
                type: 'boolean',
                set: function () {
                    debugger;
                }
            }
        }
    });
    can.Component.extend({
        tag: 'feature-icon',
        template: can.view('/modules/components/feature-icon/feature-icon.stache'),
        viewModel: Model
    });

The debugger is never called

I know the value in hasMedia is initially set to false and is later set to true
Mohamed Cherif Bouchelaghem
@cherifGsoul
use has-mediaas attribute in the component
Christopher Oliphant
@RALifeCoach
The attribute value never seems to get changed in the viewModel
Mohamed Cherif Bouchelaghem
@cherifGsoul
change it to what I sugget
<feature-icon type="article" types="articles" 
                                  is-active="{{isActive}}" 
                                  has-media="{{hasMediaContent('articles')}}" 
                                  profiles-URL="options.profilesURL"></feature-icon>
Christopher Oliphant
@RALifeCoach
Thanks - that was all it took
Mohamed Cherif Bouchelaghem
@cherifGsoul
works?
Christopher Oliphant
@RALifeCoach
It is better, not sure if all is working yet
Julian
@pYr0x
@cherifGsoul great job :)
Veni vidi vici
:clap:
Mohamed Cherif Bouchelaghem
@cherifGsoul
thank you I dont know if those points exist in the docs
Christopher Oliphant
@RALifeCoach
Yes - it is working now. the attribute is has-media, but when I use it in the stache file it is hasMedia. A bit confusing.
Mohamed Cherif Bouchelaghem
@cherifGsoul
@RALifeCoach it'scanjs recommandation properties camel cased like hasMediaand template attributes hypenated like has-media
dont be confused bro :)
Christopher Oliphant
@RALifeCoach
I am easily confused. (And I am having a lot of fun.)
I just hope I am not being too much of a bother. I really appreciate all the assistance I am getting from folks here.
Matthew Phillips
@matthewp
Every time I come here and see 50+ recent messages i'm terrified but mostly excited :)
CanJS is blowing up!
Mohamed Cherif Bouchelaghem
@cherifGsoul
@matthewp we are the night watch :D
but it's the efternoon here
Matthew Phillips
@matthewp
hehe
Christopher Oliphant
@RALifeCoach
Me again. I am trying to access the view model from an event.
the view model has a function, the events tries:
this.viewModel.vmFunction();
The message is vmFunction is not a function
If I break at that statement and add a watch, this.viewModel.vmFunction returns undefined
Mohamed Cherif Bouchelaghem
@cherifGsoul
@RALifeCoach maybe full code (component, template) can help to have a quick answer
Christopher Oliphant
@RALifeCoach
Component:
    can.Component.extend({
        tag: 'player-row',
        template: can.view('/modules/components/player-row/player-row.stache'),
        helpers: helpers,
        events: {
            '.add-to-favorite click': function () {
                this.viewModel.callParent('onPinPlayer');
            }
        }
Map:
    var Map = MapBase.extend({
        define: {
            options: {
                Type: OptionsMap
            },
            pid: {
                type: 'string'
            },
            player: {
                Type: PlayerMap
            },
        },

        callParent: function (method) {
            this.attr(method)();
        },
Mohamed Cherif Bouchelaghem
@cherifGsoul
@RALifeCoach you dont have a viewModel in your component
Christopher Oliphant
@RALifeCoach
Inserted via:
            this.playerRowMap = new Map(data);
            var template = can.stache('<player-row id="player-row-' + this.pid + '"></player-row>');
            this.container.append(template(this.playerRowMap));
the view model is inserted as shown in the last snippet. When I look at the view model in debug, I can see the various properties
Mohamed Cherif Bouchelaghem
@cherifGsoul
I dont think is in the component scope
:/
can.Component.extend({
        tag: 'player-row',
        template: can.view('/modules/components/player-row/player-row.stache'),
       viewModel:Map,
        helpers: helpers,
        events: {
            '.add-to-favorite click': function () {
                this.viewModel.callParent('onPinPlayer');
            }
        }
Christopher Oliphant
@RALifeCoach
and there are other functions on the view model that are used by the stache template - and those work
The component is in a separate file from the map and they are in separate files from the main code. I wanted to keep that separation.
which leaves me with the problem of populating the viewModel with data.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Yes you can seperate ViewModelmodule
in your component this.viewModel in the component can have only the base viewModel without your VMmethods
Christopher Oliphant
@RALifeCoach
How do I insert data into the view model?
Mohamed Cherif Bouchelaghem
@cherifGsoul
via attributes
attributes in the component
Christopher Oliphant
@RALifeCoach
This model is built with objects and objects within objects and it has many, many elements. It wouldn’t make sense to put all those into attributes.
Mohamed Cherif Bouchelaghem
@cherifGsoul
:)
Christopher Oliphant
@RALifeCoach
I have read that. What are you trying to tell me?