These are chat archives for canjs/canjs

Aug 2016
Leath Cooper
Aug 09 2016 06:23

@RALifeCoach as far as I understand in 3.0 .attr no longer exists, instead there are automatically populated getters and setters, so where you would have said

let foo = this.attr('bar');

you would now say

let foo =;

and to set the value of the attribute you'd say = someValue;

unless you are trying to get an attribute from the DOM element which would be $(this.element).attr I believe(don't quote me on that part)

I mean, that last bit will work, but not sure if there's a better way within canjs
Matthew Phillips
Aug 09 2016 13:28
@halcyonandon fair enough, what would you recommend calling that package then?
Sunil George
Aug 09 2016 18:46
A quick question - I am getting these warning messages in the console when my staches are rendered -
WARN: can/view/stache/mustache_core.js: Unable to find key or helper "client.firstName".
Although the client.firstName shows up on screen, then why is the warning message thrown?
Also, how can I prevent these stache warning messages from showing up in the logs!?
Matthew Phillips
Aug 09 2016 19:09
there's a you can set
set it to 2 I think to turn those off
Sunil George
Aug 09 2016 19:10
Thanks @matthewp for your inputs. I will check on the logLevel property.
Any idea why these warning messages would come up in the first place. Is it because the key is not set on scope when the stache is rendered, but is then later and that is why is shows up on screen?!
Christopher Oliphant
Aug 09 2016 19:25
I have created a simple connect (in 3.0) for performing a get. The connect code is:
], {
    Map: Players,
    url: config.playersUrl
playersUrl is playersUrl: '/modules/page.players-redesign/player-bio/data/players.json’
When I run the code and check the network request, it is asking for "http://localhost:8090/modules/page.players-redesign/player-bio/null?"
can I issue a get on a json file? does a get have to have id data provided?
Here is my get:
Matthew Phillips
Aug 09 2016 19:57
@georgesunil81 that's exactly why you get the warnings
if you give them an initial value the warnings will go away
Sunil George
Aug 09 2016 20:39
Thanks so much @matthewp. Will do.
Another hopefully quick question - I am trying to use jquery to scroll to the bottom of my div like below -
$("#message-thread-panel").animate({ scrollTop: $('#message-thread-panel').prop("scrollHeight")}, 1);
Sunil George
Aug 09 2016 20:44
The div is inside a stache file that gets populated by scope variables (which in turn get populated via API calls). The problem I am facing is that the scroll sometime works and sometimes it does not. It seems that I need to execute the jquery statement only when the div is completed population. How do I wait for the stache variables to update the view and then execute the above jquery statement?
Matthew Phillips
Aug 09 2016 22:05
Listen to the change in the events
if it's a list something like '{viewModel list} length': function() { ... }
where list is the viewModel's list property
whatever the name of that property is
this will execute when the length changes
so you can do your animation there
probably best in a requestAnimationFrame
Sunil George
Aug 09 2016 22:37
Thanks @matthewp . I guess the '{viewModel list} length': function() { ... } would get called once the stache is rendered completely with all the list items. If that is the case, the animation method will indeed get the correct div height (which depends on the number of list items).