Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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)

  • Oct 15 20:26

    phillipskevin on master

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

  • Oct 15 20:26
    phillipskevin closed #5372
  • Oct 15 20:25

    phillipskevin on update-make-map

    (compare)

  • Oct 15 20:25
    phillipskevin closed #5381
Christopher Oliphant
@RALifeCoach
That’s similar to what I have
Leath Cooper
@IcculusC
however I'm not using the events object in the viewmodel obviously
instead when I create a function on the view model I use the ($event) syntax
but that seems to be extremely broken
            <button type="button" class="btn btn-warning btn-large btn-block" ($event)="clicked()">Login</button>
Christopher Oliphant
@RALifeCoach
My approach is probably also broken
Leath Cooper
@IcculusC
are you using a DefineMap
Christopher Oliphant
@RALifeCoach
They both probably use the same underlying, broken, code
I have tried Map and DefineMap
I have more luck with Map
Leath Cooper
@IcculusC
have you tried logging out the value of this.viewModel
and just looking at the structure of it
Christopher Oliphant
@RALifeCoach
I’ll do that now
Leath Cooper
@IcculusC
that's how I traced my bug back to can-stache-bindings
Christopher Oliphant
@RALifeCoach
It is still uninstantiated
Leath Cooper
@IcculusC
try logging "this"
can you link your component code one more time too I can't find it
this laptop is crap
Christopher Oliphant
@RALifeCoach
here is the whole thing:
import Component from 'can-component';
var DefineMap = require('can-define/map/map');
var Map = require('can-map');
import $ from 'jquery';
import stache from 'can-stache';
import template from './player-bio.stache!';
import Players from '../models/players-model';
import PlayerBio from '../models/player-bio-model';
import PlayerResults from '../models/player-results-model';
import PlayerStats from '../models/player-stats-model';
import PlayerStat186 from '../models/player-stat186-model';
require('bootstrap/dist/css/bootstrap.css');
require('./player-bio.less');
require('./player-bio-ad');
require('can-view-model');

var PlayerBioViewModel = DefineMap.extend({
    name: 'Select Player',
    personalInfo: {
        value: Object,
        Type: PlayerBio
    },
    personalResults: {
        value: Object,
        Type: PlayerResults
    },
    personalStats: {
        value: Object,
        Type: PlayerStats
    },
    personalStat186: {
        value: Object,
        Type: PlayerStat186
    },
    playerList: {
        players: []
    },
    showMetric: false
});

Component.extend({
    tag: 'pgat-player-bio',
    template,
    viewModel: PlayerBioViewModel,
    events: {
        inserted: function () {
            Players.get({ id: 'id' }).then($.proxy((data)=>{
                this.onPlayersData(data);
            }, this));
            console.log(this);
        },
        '.switcher click': function () {
            this.viewModel.attr('showMetric', !this.viewModel.attr('showMetric'));
        },
        '.dropdown-icon click': function () {
            $('.dropdown').removeClass('hidden');
            $('.dropdown-content').removeClass('hidden');
        },
        '.player-select click': function (element) {
            $('.dropdown').addClass('hidden');
            $('.dropdown-content').addClass('hidden');
            var playerId = $(element).attr('data-id');
            PlayerBio.get({ id: playerId }).then($.proxy((data)=>{
                this.onPlayerBioData(data);
            }, this));
            PlayerResults.get({
                id: playerId,
                year: '2016'
            }).then($.proxy((data)=>{
                this.onPlayerResultsData(data);
            }, this));
            PlayerStats.get({
                id: playerId,
                year: '2016'
            }).then($.proxy((data)=>{
                this.onPlayerStatsData(data);
            }, this));
            PlayerStat186.get({
                id: playerId
            }).then($.proxy((data)=>{
                this.onPlayerStat186Data(data);
            }, this));
        },

        onPlayerBioData: function (playerBio) {
            playerBio.countryCode = this.players[playerBio.playerId].countryCode;
            this.viewModel.attr('name', playerBio.name);
            this.viewModel.attr('personalInfo', playerBio);
        },

        onPlayerResultsData: function (playerResults) {
            this.viewModel.attr('personalResults', playerResults);
        },

        onPlayersData: function (playerList) {
            this.players = {};
            playerList.players.forEach((player)=>{
                this.players[player.playerId] = player;
            });
            this.viewModel.playerList = playerList;
        },

        onPlayerStat186Data: function (playerStat186) {
            this.viewModel.attr('personalStat186', playerStat186);
        },

        onPlayerStatsData: function (playerStats) {
            this.viewModel.attr('personalStats', playerStats);
        }
    }
});

$(document.body).append(stache('<pgat-player-bio></pgat-player-bio>'));
Leath Cooper
@IcculusC
capitalize the v in viewModel on your component definition
like where it says viewModel: PlayerViewModel or whatever
this laptop has a cell phone processor hard to scroll up lol
Christopher Oliphant
@RALifeCoach
now can-map is blowing up with computedAttr.compute is not a function
Leath Cooper
@IcculusC
is it a define map or a map
Christopher Oliphant
@RALifeCoach
DefineMap
Leath Cooper
@IcculusC
oh
because .attr no longer exists
so basically when you use DefineMap you need to pass it into the ViewModel field not the viewModel field on the component definition
no idea why
and when I wa susing map I had to create an instance of the view model manually
like
Christopher Oliphant
@RALifeCoach
I am using DefineMap and I am passing it to ViewModel. And experiencing a whole new exception being thrown
Leath Cooper
@IcculusC
viewModel: new ViewModelMap()
because you're using attr
attr doesn't exist with DefineMa
p
Christopher Oliphant
@RALifeCoach
Most of the references to attr are not being used. The key line is this.viewModel.playerList = playerList
Leath Cooper
@IcculusC
does the view model exist when you use ViewModel rather than viewModel
if you log it out
Christopher Oliphant
@RALifeCoach
It crashes loading the component - so I can’t tell
Leath Cooper
@IcculusC
:(
Christopher Oliphant
@RALifeCoach
I will instantiate it outside the component and see what I get
Leath Cooper
@IcculusC
wish I could help more but I'm not knee deep in the code like you haha
Christopher Oliphant
@RALifeCoach
okay - you have helped some
thanks for your time
Leath Cooper
@IcculusC
any time
I'm here trying to learn 3.0 too
Christopher Oliphant
@RALifeCoach
It’s working!!
Leath Cooper
@IcculusC
lol what did you do
Christopher Oliphant
@RALifeCoach
I found an error in one of my sub-maps