These are chat archives for canjs/canjs

30th
Oct 2015
reno1979
@reno1979
Oct 30 2015 08:17
Ehh what happened? Canjs 2.3 does not seem to work in my current setup, 2.2.9 did fine.
The 2.3.1 version can't be build on the website
reno1979
@reno1979
Oct 30 2015 10:22
mmm it where problems with reserved attribute names, missing multiple though
Mihai Fantana
@fantanamihai
Oct 30 2015 10:42

Hi guys.
Using can 2.2.9, I have the following issue:

can.Model.extend('A', {
findOne: function(p) {
return $.ajax({type: 'get', url: '/test/'+p.a});
}
}, {});

A.extend('B', {
findOne: function(p) {
p.a = 2;
return this._super(p);
}
}, {});

When I call findOne on B, I get there is no _super:

A.findOne({a:1}) => /test/1
B.findOne({c:3}) => this._super is undefined

Can you please explain what am I doing wrong here?

Andrei Balmus
@abalmush
Oct 30 2015 15:10
hey guys, Is it possible to use “swipelef” and “swiperight” events inside component?
tried this - can.Component {... events: { “.content swipeleft”, “handler” }} and it wont work
Matthew Phillips
@matthewp
Oct 30 2015 15:25
are those real events?
Andrei Balmus
@abalmush
Oct 30 2015 17:58
hi @matthewp, yes it works if I use $(’selector’).on(“swipeleft”, function() {});
Actually I have a navigation component (can.Component) for mobile devices and I want to add this event to hide and show my compoennt on swipe left or right
Andrei Balmus
@abalmush
Oct 30 2015 18:04
Sorry guys, my fault i forgot about jquery mobile library :D i should include it to my project
dylanrtt
@dylanrtt
Oct 30 2015 19:52

I want to do something like:

{{#each myList}}
  <foo-bar {^.}="*item"></foo-bar>
  {{#if *item.isCool}} stuff {{/if}}
{{/each}}

but the last one will always overwrite the previous ones due to reference exports being scoped to the template level. Any solution? I was thinking I could throw {{%index}} into the name but that's not supported yet (stache doesn't process custom attrs... yet) and I would have to make a special helper to replace the #if functionality.

Justin Meyer
@justinbmeyer
Oct 30 2015 19:53
@dylanrtt similar to how JS doesn't have block level-scope
neither does a template
I thought about adding it ... but for performance reasons, I didn't
it involves creating an extra scope each time
and extra scope walking times
however, if you want to create a helper that adds scope, that should be pretty easy
registerHelper("ref", function(options){
  return options.fn( new can.view.Scope.Refs() )
})
{{#each myList}}
  {{#ref}}
  <foo-bar {^.}="*item"></foo-bar>
  {{#if *item.isCool}} stuff {{/if}}
  {{/ref}}
{{/each}}
something like that would work
should work
I think there was another issue to allow inline partials
dylanrtt
@dylanrtt
Oct 30 2015 19:57
@justinbmeyer Nice! I'll try it out. Thanks!
Justin Meyer
@justinbmeyer
Oct 30 2015 19:57
worst-case is you can define another template
Kevin Phillips
@phillipskevin
Oct 30 2015 23:29
Is it correct that the new 2.3 bindings syntax is opt-in? If you don’t have the can/view/bindings plugin, stache will still use the old binding syntax, right?
dylanrtt
@dylanrtt
Oct 30 2015 23:30
@phillipskevin I'm pretty sure can/view/bindings is core, not a plugin.
You can still use the old binding syntax though.
dylanrtt
@dylanrtt
Oct 30 2015 23:39
The old and new share a lot of the same logic so any defects in the new syntax will likely be present with the old syntax too. For instance, can-value essentially became an alias for {($value)}, and foo="{bar}" works the same as {(foo)}="bar", though they may slightly diverge in an upcoming patch to prevent backwards compatibility issues.
Kevin Phillips
@phillipskevin
Oct 30 2015 23:54
ok, that was my initial thought, but the docs call it a plugin so I wasn’t sure
dylanrtt
@dylanrtt
Oct 30 2015 23:55
Yeah that's probably the correct term to use but can/component depends on it so I'm not sure what an opt-out process would look like
Kevin Phillips
@phillipskevin
Oct 30 2015 23:56
yeah, you’re right
it’s included in stache and mustache by default as well
thanks, I should have just checked that initially