Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 16 20:07
    matthewp commented #5384
  • Oct 16 20:06
    matthewp labeled #5384
  • Oct 16 20:06
    matthewp opened #5384
  • Oct 16 19:53
    matthewp opened #5383
  • Oct 16 16:23
    phillipskevin closed #4841
  • Oct 15 21:43

    phillipskevin on master

    Update dist for release (compare)

  • Oct 15 21:43

    phillipskevin on v6.1.1

    Update dist for release 6.1.1 (compare)

  • Oct 15 21:34

    phillipskevin on can-observable-mixin-1.0.2

    (compare)

  • Oct 15 21:34

    phillipskevin on master

    fix(package): update can-observ… Merge branch 'master' into gree… Merge pull request #5382 from c… (compare)

  • Oct 15 21:34
    phillipskevin closed #5382
  • Oct 15 21:34

    phillipskevin on can-make-map-1.2.2

    (compare)

  • Oct 15 21:34

    phillipskevin on master

    fix(package): update can-make-m… Merge pull request #5380 from c… (compare)

  • Oct 15 21:34
    phillipskevin closed #5380
  • Oct 15 20:30
    phillipskevin synchronize #5382
  • Oct 15 20:30

    phillipskevin on can-observable-mixin-1.0.2

    fix(package): update can-observ… fix(package): update can-simple… Merge pull request #5372 from c… and 2 more (compare)

  • Oct 15 20:30
    phillipskevin opened #5382
  • Oct 15 20:28

    phillipskevin on can-simple-map-4.3.3

    (compare)

  • Oct 15 20:28

    phillipskevin on master

    fix(package): update can-simple… Merge pull request #5378 from c… (compare)

  • Oct 15 20:28
    phillipskevin closed #5378
  • Oct 15 20:26

    phillipskevin on can-observable-mixin-1.0.1

    (compare)

Matthew Phillips
@matthewp
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?
Mohamed Cherif Bouchelaghem
@cherifGsoul
I want to tell you it makes sens :)
maybe I didnt understand well what are you looking for
Christopher Oliphant
@RALifeCoach
I am to create a stache element with 100+ attributes?
Mohamed Cherif Bouchelaghem
@cherifGsoul
you want to pass all of theme to a component?
Christopher Oliphant
@RALifeCoach
yes
it’s a big piece of code!
Mohamed Cherif Bouchelaghem
@cherifGsoul
those attrs values are loaded from the server I supose?
Christopher Oliphant
@RALifeCoach
You suppose correctly. :-)
Mohamed Cherif Bouchelaghem
@cherifGsoul
In this case you need a can.Model
I hope you have one
Christopher Oliphant
@RALifeCoach
No I do have one. In this case the data is being retrieved by another module all together and being passed to this module. (The original file contains many rows. This module is just one row.)
So can.Model will not help.
I could create the properties as an JSON object and return it via a fixture - but this is now getting very complicated
Mohamed Cherif Bouchelaghem
@cherifGsoul
fixtures for production code?
Christopher Oliphant
@RALifeCoach
exactly - not something I want to do
Therefore I need another suggestion.
I currently instantiate the Map outside of the component and then pass the map into the template when adding the stache template into the page. That way I can update the map data and it is reflected in the html.
Christopher Oliphant
@RALifeCoach
Everything was working until I tried to wire in an event. The event was originally being wired through jQuery bind’s. I could continue to use that, but I wanted to wire the event into the component.
@cherifGsoul any suggestions?
Mohamed Cherif Bouchelaghem
@cherifGsoul
the case is complicated
Kevin Phillips
@phillipskevin
sorry to recap, your problem is that this.viewModel is undefined when you set it up like template(this.playerRowMap) ?