These are chat archives for canjs/canjs

30th
Aug 2016
Christopher Oliphant
@RALifeCoach
Aug 30 2016 02:08
I have a stache template that is a loop. Inside the loop there is another template. That template also includes a loop. Every 10 seconds I re-read the file and update the viewModel with the new data. When I do that the screen flickers as it is being redrawn. This is a surprize since the data being shown is identical.
I have tried {{#key}} and {{#each key}} - both flicker
Christopher Oliphant
@RALifeCoach
Aug 30 2016 10:52
Any ideas on the flicker?
Eben
@eben-roux
Aug 30 2016 10:58
@RALifeCoach canjs probably won't be comparing the data --- so if you change just the bits that need changing it may improve the flickering. However, it does sounds like excessive redrawing. Is there no mechanism in canjs that can batch these operations...
typically there would be a start and finish type of thing
Christopher Oliphant
@RALifeCoach
Aug 30 2016 10:59
The whole point of CanJS is to create observables and only update when they change.
Eben
@eben-roux
Aug 30 2016 10:59
don't know enough about canjs but I can only imagine that something to this effect should exist
true, however, most UIs suffer when there is excessive redrawing
Eben
@eben-roux
Aug 30 2016 12:20
AH!
@RALifeCoach would this not do the trick: https://canjs.com/docs/can.batch.html
Christopher Oliphant
@RALifeCoach
Aug 30 2016 12:30
That is a 2.3 facility. I understood that in 3.0 batching was built in. Is that correct?
Eben
@eben-roux
Aug 30 2016 12:34
oh yes... v3.0 :) --- I have no idea... would be cool but I don't know to what extent something like that would work. I have seen similar user-controlled batching from WinForms to Ember so I would be quite impressed if this probelm is overcome automatically (perhaps using some timing mechanism --- who knows)
Sunil George
@georgesunil81
Aug 30 2016 16:07
A quick question - I have a button element with attributes as below -
 <button type="button" class="btn" ($click)='openTask(id)'>Open Task</button>
How do I get the element in my openTask function. I do get the id, but I would like the element (el) and event (ev) too. Any idea?
Kevin Phillips
@phillipskevin
Aug 30 2016 16:11
openTask(id, %element, %event)
Sunil George
@georgesunil81
Aug 30 2016 16:12
Ah! Thanks @phillipskevin Will try it now.
Christopher Oliphant
@RALifeCoach
Aug 30 2016 16:14
@phillipskevin Any insight on my flickering issue?
Kevin Phillips
@phillipskevin
Aug 30 2016 16:16
so, however you’re overwriting the list is firing remove and add events
I don’t really have a good suggestion about how to avoid it
how are you setting the list?
Christopher Oliphant
@RALifeCoach
Aug 30 2016 16:19
I am using 3.0 and I understand that all I have to do is this.list = myList;
Sunil George
@georgesunil81
Aug 30 2016 16:19
@phillipskevin , I do get element as button but I am not able to change its html from 'Open Task' to 'Task Opened'!
I am doing el.prop('value', 'Task Opened') within the openTask function and it says .prop is not a function!
Is there a way in CanJS to change the label of the button?
Sunil George
@georgesunil81
Aug 30 2016 16:30
I also tried el.button( "option" , "label", "custom label" ), but it didn't work either!!! Please help.
Kevin Phillips
@phillipskevin
Aug 30 2016 16:33
@georgesunil81 you should use your viewmodel to set the label. Instead of modifying the dom directly.
@RALifeCoach you can do it like that. You can also try using replace. Although I'm not positive if that will solve your issue.
Sunil George
@georgesunil81
Aug 30 2016 16:36
@phillipskevin , but the problem is that there is a series of buttons with no unique identifier on it. So, I thought, let me get the element when the event happens and use that as a handle and use jquery to change the label.
But, what I am finding is that %element gives the text of the element (ie. the entire <button>...</button> as a text) and not something that I can use with jquery!
Kevin Phillips
@phillipskevin
Aug 30 2016 16:40
It's a dom element. So if you want to use it with jquery, you'll have to wrap it with jquery.
Sunil George
@georgesunil81
Aug 30 2016 16:41
How do I do that? Coould you help.
with an simple and quick example
Kevin Phillips
@phillipskevin
Aug 30 2016 16:43
Import jquery and do $(el)
Sunil George
@georgesunil81
Aug 30 2016 16:44
Okay @phillipskevin thanks, I am trying that...
Yes @phillipskevin , that worked. Thanks a ton for your help on this.
Kevin Phillips
@phillipskevin
Aug 30 2016 16:46
Sure