These are chat archives for canjs/canjs

19th
Aug 2015
espretto
@espretto
Aug 19 2015 09:11
i meant to write $elem.html(stache(tags.map(function (tag) { ... }).join('')));
Aggelos Karalias
@mehiel
Aug 19 2015 11:23
@espretto I'm pretty confident that's not leaking.. .html() should call destroy in the included components.. I suppose a naive test is to create a destroy method in the events of an inner component and see if that's called when you replace stuff with .html()
Nezar Fadle
@nezarfadle
Aug 19 2015 19:00
Hi guys , Is there any articles for newbie explain how to make the components globally available to the system and the other components as well :)
Jan Jorgensen
@ramblinjan
Aug 19 2015 20:16
@nezarfadle could you give an example of what you're trying to do?
Nezar Fadle
@nezarfadle
Aug 19 2015 20:24

Let's assume that I have a generic message component which is gonna display a simple message
with a title:

components/message/message.js
components/message/message.stache

var MessageModel = can.Map.extend({
title: "",
message: ""
});

can.Component.extend({
tag: 'message-widget',
viewModel: MessageModel,
template: can.view('/components/message/message.stache')
});

And I have another component called Order:

components/order/order.js
components/order/order.stache

I want the message component to be available to the order component and both of them available globally to the system or any other component calling them

dylanrtt
@dylanrtt
Aug 19 2015 20:28
@nezarfadle you could make a "lib" module for example that imports all of the modules you want to be "global". Anything needing to use the message component for example could import "lib"
I'm not sure of a way to make them truly global since you would have to ensure they load first somehow
Nezar Fadle
@nezarfadle
Aug 19 2015 20:32
Let me make it more clear ... In other words .. I wanna build a modular application, But I didn't know what is the right way to deal with the Modules Loader :'(
dylanrtt
@dylanrtt
Aug 19 2015 20:35
Now I'm more confused... are you saying you don't know how to use a module loader? Which one are you using?
Nezar Fadle
@nezarfadle
Aug 19 2015 20:40
I tried to use require.js, But I had no luck, And now I'm trying to play with steal.js, But there are too many stuff are not clear !!
Marshall Thompson
@marshallswain
Aug 19 2015 20:40
@nezarfadle Have you gone through the getting started guide?
Nezar Fadle
@nezarfadle
Aug 19 2015 20:43
Yes, But most of it just shows you how to build everything in on single page,, It doesn't show you how to build a modules and make them call and pass data to each other + The routing part is not that clear
dylanrtt
@dylanrtt
Aug 19 2015 20:48
Passing data between modules in CanJS is usually done by passing data between Components in the template. You can even import your components in the template layer if you want. Simply importing them should register the custom tag for use.
Nezar Fadle
@nezarfadle
Aug 19 2015 20:51
The problem the I'm coming from a PHP background ,, I'm just looking for example shows me how to do a very simple primitive modular app in the right way specially with Loading modules and routing :)
Any way .. I will try to do more research and I will see how .. because I feel that the problem in me ,, maybe I lack some knowledge,, Thanks guys ,, ^_^
@dylanrtt ,, tnx man .. I'm gonna take a look at it :)
dylanrtt
@dylanrtt
Aug 19 2015 20:54
@nezarfadle here's are some examples of modular components with demo pages showing how they are used https://github.com/bitovi-components
place-my-order is designed to be a more complex example including more features like routing https://github.com/donejs/place-my-order
Nezar Fadle
@nezarfadle
Aug 19 2015 20:58
@dylanrtt I will take a look at them ,, tnx man :+1: :+1: