These are chat archives for canjs/canjs

20th
Jul 2016
Kevin Phillips
@phillipskevin
Jul 20 2016 20:49
Great! Glad to hear it.
Sunil George
@georgesunil81
Jul 20 2016 21:21
@phillipskevin a quick question, is there a recommended way to refresh a view (template) that has been rendered by a can.control?
Kevin Phillips
@phillipskevin
Jul 20 2016 21:23
live binding?
not sure what you mean I guess
Sunil George
@georgesunil81
Jul 20 2016 21:26
Oh! I have an init function within can.control that makes a call to a model, gets data and renders the view. I wanted to provide a refresh button in the view that will allow the user to refresh. I was thinking on the lines of calling the init again, but I guess I cannot do that.
init is automatically called when the can.control is instantiated I think. There may not be a way to call the init again on the click event of refresh button.
I was not sure there.
Kevin Phillips
@phillipskevin
Jul 20 2016 21:28
why would the user refresh?
Sunil George
@georgesunil81
Jul 20 2016 21:29
The database can have more task records that would have been created (by other users) while the user had the view open.
I wanted the user to have the ability to hit a refresh button when they want to.
Adam L Barrett
@BigAB
Jul 20 2016 21:31
Is there a way to determine that a function is a can.Map constructor function (like what’s reuturned from can.Map.extend()) and not just a regular function or some other constructor function (one that won’t create a can.Map) ?
Kevin Phillips
@phillipskevin
Jul 20 2016 21:31
the simplest way is to just move the model call and view rendering to another function
call that from init and call it from your refresh function @georgesunil81
Sunil George
@georgesunil81
Jul 20 2016 21:33
Wow, I could do that. And since the view is live-bound, it will automatically show the new data whenever the scope object for the view updated with the new task records.
Sunil George
@georgesunil81
Jul 20 2016 21:41
Thanks @phillipskevin
Alexis Abril
@alexisabril
Jul 20 2016 21:45
@BigAB
const Item = can.Map.extend();
console.log(Item.prototype instanceof can.Map);
Adam L Barrett
@BigAB
Jul 20 2016 21:51
@alexisabril Of course! Thanks