These are chat archives for canjs/canjs

25th
Oct 2018
I think that video/guide show it ...
I do something like:
<input value:bind="todo.name" on:change="todo.save()"/>
Justin Meyer
@justinbmeyer
Oct 25 2018 01:30
I've started putting up new stache docs too: https://canjs.com/doc/can-stache.html
Julian
@pYr0x
Oct 25 2018 07:35
@justinbmeyer i used the approache before too. but i had two problems:
  1. i want to debounce the saving, because i use on:input:value:to="todo.name". if i add on:input=todo.save(). there is no debouncing. so i need a debounce function inside my VM
  1. if i have 100 items, is it worth to put on every input an event listener? i thought it meight by better so listen on changes on the Model in the VM
Julian
@pYr0x
Oct 25 2018 07:50
@justinbmeyer good work for updating the stache docs :100:. one more thing i would like to see is basic and simple animation
Viktor Busko
@Lighttree
Oct 25 2018 09:28
https://canjs.com/doc/can-stache.tags.named-partial.html
This "Partial" section refers to {{> expression}} that moved to "Deprecated" section.
It seems that you can't use "partials" without {{> expression}} so probably it shouldn't be in "Deprecated" section ?
Julian
@pYr0x
Oct 25 2018 09:33
jep
kostya.aderiho
@kaderiho
Oct 25 2018 10:48

Hi guys, I have a case when I need to swap 2 elements inside of DefineList, so I did it through the temp variable like this:

let swappedItem = this.viewModel.itemsList[x];
this.viewModel.itemsList[x] = this.viewModel.itemsList[y];
this.viewModel.itemsList[y] = swappedItem;

I see that my list is updated, but I don't see updates on UI where I use {{#each(itemsList, num=index) ....

Do you have any ideas why it doesn't work and what is the appropriate way of doing it?

Thanks

kostya.aderiho
@kaderiho
Oct 25 2018 12:01
yeah this approach works, thanks you!
Justin Meyer
@justinbmeyer
Oct 25 2018 14:15
@pYr0x keep voting for this: canjs/canjs#3864 ... or maybe you could add to the .md file a section showing something like:
<div on:someEvent:by:item="animate()"/>
@pYr0x you could also create a helper that debounces
the best solution would probably be to make a can-connect behavior that works with the instance store .... it would listen to changes on instances and automatically save them if they are in the store
http://localhost:8080/canjs/doc/can-event-queue/type/type.can.onInstancePatches.html
Todo[Symbol.for("can.onInstancePatches")]( function(instance, patches){
  // check if `instance` is in the store
  // debounce an `instance.save()` call
})
this would make the behavior "global" for that type
and not make it happen on a specific form or something
for that, I would probably do something in connectedCallback
Justin Meyer
@justinbmeyer
Oct 25 2018 14:20
@Lighttree you can use partials w/o {{> expression }}, this section shows all the ways: https://canjs.com/doc/can-stache.html#Creatingpartials
essentially, call expressions can call views now ...
so {{>}} isn't really needed
{{>}} works a bit different, but I think call expressions can do everything