These are chat archives for canjs/canjs

17th
Apr 2015
James Atherton
@James0x57
Apr 17 2015 17:27
I have a component with an event on an element and I'd like the event function to call a function on that element's view model ... can I 'reach' the VM from the event?
$el.scope() is empty, I thought that was what it did though.
Matthew Phillips
@matthewp
Apr 17 2015 17:28
this.scope.nameOfFunction
James Atherton
@James0x57
Apr 17 2015 17:29
awesome, thanks! I was close :P
Matthew Phillips
@matthewp
Apr 17 2015 17:33
it's a map so you can get more than the functions
this.scope.attr('someProperty')
largoelks
@largoelks
Apr 17 2015 19:56
If I've installed bit-tabs 0.0.5 via npm can I just import them like this? import Tabs from 'bit-tabs';
Or is there more path set up I need?
Matthew Phillips
@matthewp
Apr 17 2015 19:57
nope, that works
using stealjs i presume?
largoelks
@largoelks
Apr 17 2015 20:00
yep using steal but I get an error
TypeError: Error loading "bit-tabs@0.0.5#tabs.stache!can@2.2.4#view/stache/system" at <unknown> Error loading "bit-tabs@0.0.5#tabs.stache!can@2.2.4#view/stache/system" from "main" at http://localhost:63342/testapp/main.js Cannot read property 'default' of undefined
TypeError: Error loading "bit-tabs@0.0.5#tabs.stache!can@2.2.4#view/stache/system" at <unknown>
Matthew Phillips
@matthewp
Apr 17 2015 20:03
which version of steal?
largoelks
@largoelks
Apr 17 2015 20:03
"steal": "^0.8.0" and "canjs": "^2.2.0-alpha.9"
Matthew Phillips
@matthewp
Apr 17 2015 20:04
oh, you want to use the "can" npm package
largoelks
@largoelks
Apr 17 2015 20:05
the what?
A different can?
Matthew Phillips
@matthewp
Apr 17 2015 20:05
no... we are publish "can"
we should put a notice on the "canjs" one
to use "can" instead
largoelks
@largoelks
Apr 17 2015 20:08
ok so - npm install can --save (instead of the incorrect canjs)
cando
Matthew Phillips
@matthewp
Apr 17 2015 20:09
yep
Marshall Thompson
@marshallswain
Apr 17 2015 20:09
@largoelks And with the latest Steal and Can you can can-import from the template.
<can-import from="bit-tabs"/>
<bit-tabs>
    <bit-panel title="Tab 1">
        Party in Tab 1!
    </bit-panel>
    <bit-panel title="Tab 2">
        Fiesta in Tab 2!
    </bit-panel>
</bit-tabs>
Matthew Phillips
@matthewp
Apr 17 2015 20:09
yep!
largoelks
@largoelks
Apr 17 2015 20:10
yep.. I saw that but kinda hate it... or at least until I try it
Matthew Phillips
@matthewp
Apr 17 2015 20:11
what do you hate about it?
largoelks
@largoelks
Apr 17 2015 20:11
feels like I'm giving too much control to my designer/html dev
Matthew Phillips
@matthewp
Apr 17 2015 20:12
oh, new to components then?
largoelks
@largoelks
Apr 17 2015 20:13
but I can see the value of putting the import right at use
Marshall Thompson
@marshallswain
Apr 17 2015 20:13
Yeah, you can focus on the template. I had the same first reaction. Now I love it. It gives me goose bumps. But I don’t have a separate html dev.
largoelks
@largoelks
Apr 17 2015 20:13
yep components are cool but making one have the right amount of functionality (not too big not to small) is hard
I've been looking at the bit-* stuff and it's nice
Matthew Phillips
@matthewp
Apr 17 2015 20:15
cool, hoping more people start publish their own components
Juan Orozco
@Macrofig
Apr 17 2015 20:17
I'm trying something that I can't believe I've never tried before... is there an easy way to do this can.$('cool-component').data('controls')[0]['open']() for some reason I thought I could do can.$('cool-component').open()
largoelks
@largoelks
Apr 17 2015 20:17
Yep - I need to go back and watch the last hangout. So that I can better understand how to create and especially compose components. Seems that's where the magic is
Juan Orozco
@Macrofig
Apr 17 2015 20:18
I'm trying to call a method that is in the events object. It's there because it does some DOM manipulation then triggers some viewmodel method.
dylanrtt
@dylanrtt
Apr 17 2015 20:20
@Macrofig is there a reason you can't put that method in the viewmodel and just pass it the element?
Juan Orozco
@Macrofig
Apr 17 2015 20:22
I want to be able to call it like $('component').methodName() Push come to shove, I could do $('component').viewModel.methodName()
I prefer to keep state logic in view model and dom/event logic in events but other than that, no other technical reason.
Matthew Phillips
@matthewp
Apr 17 2015 20:24
@Macrofig there as an issue about that but i believe it was never added
think about it though
$('component').methodName()
would add methodName to all jquery objects
probably not what you want
Juan Orozco
@Macrofig
Apr 17 2015 20:25
Ah yes.
that would be an undesired side effect.
Would be cool to do can.component.getInstance($('component')).methodName() or somehting like. Basically can.viewModel() but for component's events.
Morgan Heimbeck
@Xitstrategies
Apr 17 2015 20:37

is there a way to get the URL string for the Model after the model has been instantiated? var Vessel = can.Model.extend('Tt.Models.Vessel',
/ @Static /
{
findAll: "GET api://v3/basics/vessels",
findOne: "GET api://v3/basics/vessels/{id}",
create : "POST api://v3/basics/vessels",
update : "PUT api://v3/basics/vessels/{id}",
destroy: "DELETE api://v3/basics/vessels/{id}",

    init: function() {},

});
Vessel.findAllURL???
where findAllURL returns "GET api://v3/basics/vessels"

Marshall Thompson
@marshallswain
Apr 17 2015 20:39
@Macrofig take a look at #881 and #730
@Xitstrategies If you instantiate your Model with the resource property, you can access it at Model.resource.
Juan Orozco
@Macrofig
Apr 17 2015 20:41
Thanks @marshallswain ill take a look asap
Marshall Thompson
@marshallswain
Apr 17 2015 20:44
@Xitstrategies but you’d have to assemble the full URL you’re looking for manually.
Morgan Heimbeck
@Xitstrategies
Apr 17 2015 20:48
resource was exactly what I was looking for!
thanks @marshallswain