Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 18 22:20
    greenkeeper[bot] labeled #5391
  • Oct 18 22:20
    greenkeeper[bot] opened #5391
  • Oct 18 22:20

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

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

  • Oct 18 19:08
    cherifGsoul labeled #5390
  • Oct 18 19:07
    cherifGsoul opened #5390
  • Oct 18 18:45
    greenkeeper[bot] labeled #5389
  • Oct 18 18:45
    greenkeeper[bot] opened #5389
  • Oct 18 18:45

    greenkeeper[bot] on can-observable-bindings-1.3.0

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

  • Oct 18 18:29

    matthewp on master

    Update dist for release (compare)

  • Oct 18 18:29

    matthewp on v6.1.3

    Update dist for release 6.1.3 (compare)

  • Oct 18 17:59

    matthewp on can-observable-array-1.0.2

    (compare)

  • Oct 18 17:59

    matthewp on master

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

  • Oct 18 17:59
    matthewp closed #5388
  • Oct 18 16:46
    greenkeeper[bot] labeled #5388
  • Oct 18 16:46
    greenkeeper[bot] opened #5388
  • Oct 18 16:46

    greenkeeper[bot] on can-observable-array-1.0.2

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

  • Oct 18 12:45
    greenkeeper[bot] labeled #5387
  • Oct 18 12:45
    greenkeeper[bot] opened #5387
  • Oct 18 12:45

    greenkeeper[bot] on can-stache-element-1.0.2

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

  • Oct 18 09:49
    chasenlehara edited #5384
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) ?
Christopher Oliphant
@RALifeCoach
The viewModel is defined. But the attrs are buried. and I can’t access them via this.viewModel.attr(‘xxx’).
Mohamed Cherif Bouchelaghem
@cherifGsoul
@phillipskevin here is the 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');
            }
        }
the component viewModel prop is emplty
Kevin Phillips
@phillipskevin
right, I saw that
Mohamed Cherif Bouchelaghem
@cherifGsoul
as I understand he wants to copy other external viewModel properties to component props
Christopher Oliphant
@RALifeCoach
when I break on that statement and watch on this.viewModel it says it is a Constructor. When I open the object I see _data, when I open _data, I see %root, when I open that I see my properties.
Mohamed Cherif Bouchelaghem
@cherifGsoul
so this.viewModel.attr('%root').attr('prop')
Christopher Oliphant
@RALifeCoach
That works.
That isn’t exactly intuitive, but it works. Thank-you.
Kevin Phillips
@phillipskevin
I think it would simplify things a lot if we could figure out a way to pass the viewmodel in the conventional way
Christopher Oliphant
@RALifeCoach
Actually, this is a really nice way of handling things. With the map being instantiated outside of the component lets me update the map as needed and that automatically updates the html. For really large systems and legacy systems, this is a real boon.