These are chat archives for canjs/canjs

1st
May 2015
Gerard Finnerty
@halcyonandon
May 01 2015 01:15
hey, anyone run into an issue where you have a component, then absolutely position it and all event bindings except {document} ones break? I'm trying to use a component as the content for a bootstrap popover, which does not work well, so i tried adding the component to the dom as display: none and injecting into the bootstrap popover, but then the component does not work at all
i also ran into this in a separate case where i created a responsive view of something, that responsive view becomes absolutely positioned, when that happens, the component stops working
Justin Meyer
@justinbmeyer
May 01 2015 01:39
@halcyonandon I've not seen that happen
are you sure you are just positioning the element?
it sounds like it might becoming detached temporarily from the dom
simply setting style.position = "absolute"
should do nothing
largoelks
@largoelks
May 01 2015 17:06
Are name spaced events supported with can.Componet templated event handlers?
Do I need to configure it somehow?
Brian Moschel
@moschel
May 01 2015 17:51
namespaced in what way?
can.Component's "event" property is just a can.Control under the hood, so the same rules apply
@largoelks ^
largoelks
@largoelks
May 01 2015 17:55
with jquery I can do this - this.element.find('.tree-control').on('changed.jstree', function(){}) but I don't seem to be able to do this. '.tree-control changed.jstree': function(el, ev, data) {}
So using the changed.jstree
dylanrtt
@dylanrtt
May 01 2015 19:20
I am trying to narrow down a memory leak in my app and I am getting some weird results with just a model and a template. Maybe somebody could shed some light on why the number of bindings keeps increasing? http://jsbin.com/rewiwiritu/1/edit?js,console,output
Ilya Fadeev
@ilyavf
May 01 2015 20:30
can.component.extend: if I have a parent component with a viewModel, then I extend it with another viewModel, the original viewModel is not available for this child component?
dylanrtt
@dylanrtt
May 01 2015 20:32
I believe that is correct. If you keep your parent component's viewmodel definition separate with can.Map.extend, you could probably extend that and use it in the child component
Ilya Fadeev
@ilyavf
May 01 2015 20:35
ah, i see. So, then inside the init function i can access the definition and use it, is this what you mean?
dylanrtt
@dylanrtt
May 01 2015 20:37
I mean that you can assign the viewmodel in the component definition to a map constructor like in the bitovi-components examples (https://github.com/bitovi-components/bit-tabs/blob/master/src/bit-tabs.js). Then create a new viewmodel definition for the child and assign it to the child component in the definition
Ilya Fadeev
@ilyavf
May 01 2015 20:41
oh, i see... but this kinda breaks the encapsulation for my component - i have to expose both: my parent component and its viewModel, separately.
i am wondering if i can access parent's viewModel from inside the init function of the child component...
dylanrtt
@dylanrtt
May 01 2015 20:42
I actually like separating the viewmodel definition because it allows you to test it separately, as well as extend it on its own
Ilya Fadeev
@ilyavf
May 01 2015 20:43
thats a good point! =)
how can i plug in the super plugin? (http://canjs.com/docs/can.Construct.super.html)
Brian Moschel
@moschel
May 01 2015 20:50
@ilyavf you don't have to do anything special besides loading the file, and calling this._super from any construct method
@dylanrtt I'm taking a look at your jsbin
Ilya Fadeev
@ilyavf
May 01 2015 21:02
@dylanrtt so, the same applies to the events object - it gets replaced by the child's extend...
Brian Moschel
@moschel
May 01 2015 21:02
@ilyavf i don' t believe there is a can.component.extend
where do you see that in the docs?
also why does gitter put my recent messages above my less recent ones
this makes no sense
Brian Moschel
@moschel
May 01 2015 21:03
ah :)
you are right
Ilya Fadeev
@ilyavf
May 01 2015 21:04
so, this was intended to be used only for creating a components, not to build a hierarchy, right?
like: gridComponent, scrollingGridComponent, etc
Brian Moschel
@moschel
May 01 2015 21:04
yes, in other words, its not intended to let you inherit from a component
thats just the constructor for a single component
dylanrtt
@dylanrtt
May 01 2015 21:05
I'm not sure that component inheritance was ever fully developed. I was hoping to start doing it with grids pretty soon
Brian Moschel
@moschel
May 01 2015 21:05
the best way to do component inheritance is via wrapper component
*components
so like create a base-grid
and then a component that wraps it, like sales-grid
Ilya Fadeev
@ilyavf
May 01 2015 21:06
how would i wrap a component?
Brian Moschel
@moschel
May 01 2015 21:06
are my messages showing up in reverse for you guys too?
Ilya Fadeev
@ilyavf
May 01 2015 21:06
its ok for me
Brian Moschel
@moschel
May 01 2015 21:06
wtf, very distracting
dylanrtt
@dylanrtt
May 01 2015 21:07
gitter seems to be pretty buggy. it constantly crashes on me or gives me notifications about messages that happened hours ago
Brian Moschel
@moschel
May 01 2015 21:07
so to wrap a component, create a base-grid, then create a sales-grid
and in the sales-grid template
have <base-grid attr1="{foo}"...
so you're instantiating the base from the thing that inherits from it, and passing anything in that it needs
does that make sense?
Ilya Fadeev
@ilyavf
May 01 2015 21:09
oh, i see. So, I should see a Component as more like a web-component, kinda driven from html? and not as a "class" to be extended...
Brian Moschel
@moschel
May 01 2015 21:09
yes
correct
Ilya Fadeev
@ilyavf
May 01 2015 21:11
ok, thank you guys!
dylanrtt
@dylanrtt
May 01 2015 21:12
If you really want to extend them, the framework isn't exactly going to stop you (yet). You just have to do more manual calls to get the parent functionality. For instance, you could do this in the child Parent.prototype.events.inserted.apply(this, arguments);
Brian Moschel
@moschel
May 01 2015 21:12
yeah you could do that
there was a PR that could address this: bitovi/canjs#1298
dylanrtt
@dylanrtt
May 01 2015 21:12
since _super only works with the functions declared on the component itself (not the events object) as far as I can tell
Brian Moschel
@moschel
May 01 2015 21:12
but we decided not to go that route
to more closely simulate web components
@dylanrtt in your jsbin
there is no $('#test')
that element isn't in the page
so i'm confused
Gerard Finnerty
@halcyonandon
May 01 2015 21:14
@justinbmeyer you're right about that, apparently, you cannot use bootstrap popovers with a component as the content. The only way is by appending the content to the element inside the bs.shown event, so I ended up having to gut bootstrap's tooltip.js, grabbing all the methods needed to handle/configure the popover, adding them to a module and exporting a can.Control to handle everything in a way that works with injecting the component into it.
dylanrtt
@dylanrtt
May 01 2015 21:14
@moschel there is a <div id="test"></div> below the buttons
Brian Moschel
@moschel
May 01 2015 21:15
oh
yeah, my mistake
Gerard Finnerty
@halcyonandon
May 01 2015 21:15
has anyone else run into issues with using bootstrap js components (popovers/modals) with canJS components?
Brian Moschel
@moschel
May 01 2015 21:20
@dylanrtt I agree that jsbin might be exposing something suspicious
i can't explain why that would still have a lingering _binding
after you remove the DOM
that's a good test case
would you mind making an issue with that in it?
and me or someone will dig on it further
dylanrtt
@dylanrtt
May 01 2015 21:22
sure, will do. thanks