I do not mean to bother you but do you mean in the Component object? Or I should design my application to just get/set properties and use the live-binding?
But if I need to call function/methods to initialize external objects I don’t see any other way.
Thanks for this exchange of ideas: it very helpful for me.
Ideally your application is just getters and methods and lets live-binding do all the work.
Yes, sometimes this breaks down and that’s why the Comonent’s events object is there. In Bitballs, we use it to work with a Youtube video. But if possible, it’s best to avoid the events object.
For instance I have a class that init a Google Map with a list of markers.
This GoogleMap is initialized when the user click on a link that will handle the display of the Component.
In this case I need to wait the Component is created (it’s tag in the stache template filled) and then init the google Map using the `event inserted of the Component.
// Map that init the main page
var status = can.Map.extend({
showMap:{
value:false
},
setShowMap: function(val){
this.showMap = val;
}
})
//can stache template of the main page
<button ($click)="setShowMap(true)">show map</button>
{{#if showMap}}
<can-import from="component/googleMap/googleMap" >
{{#if isResolved}}
<map></map>
</can-import>
{{/if}}