Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
opolyo01
@opolyo01
I don't see any examples where can.component would be instantiated inside of another can.component. Is it even possible or I have to declare it inside of the template? If it were can.Control inside of can.Component then I would simply instantiate new MyControl("#selectorId", {})
Alexis Abril
@alexisabril
@opolyo01 Yep, you’d want to use it inside a template. In one component’s template it’s common to use other components.
espretto
@espretto
somebody knows how to tell when canjs has rendered everything? i'd like to embed my app in a server-side phantom instance to serve indexable content. i chose amd over stealjs.
David Luecke
@daffl
CanJS renders synchronously so you just need to keep track of all the asynchronous loading you are doing.
2.3.0-pre also supports server side rendering now using https://github.com/canjs/can-ssr
@espretto
dylanrtt
@dylanrtt
can.param converts nested objects to bracket syntax like country[name] but my backend expects them to be like country.name in the query string. Is there an easy way to do that so it applies to all requests? should I just overwrite it?
Chris Gomez
@akagomez
@dylanrtt Maybe you can extend can.route.param: https://github.com/bitovi/canjs/blob/master/route/route.js#L203
It’ll create the bracket based nested objects, and you can replace them using a regex afterwards.
dylanrtt
@dylanrtt
well I'm using the util which I guess is jquery, not the route version, but that should work. thanks!
James Atherton
@James0x57
This message was deleted
Juan Orozco
@Macrofig
It seems like Stache doesn't like block level html inside SPAN tags. http://jsbin.com/gurezu/1/edit?html,js,output
Has anyone else seen this?
Curtis Cummings
@ccummings
I’ve seen it. We fixed it specifically for <a> tags in 2.2
Issue: bitovi/canjs#1134
PR: https://github.com/bitovi/canjs/pull/1431/files
The fix was to make the parser treat <a> like a block element, not sure we want to do the same for a span though
Juan Orozco
@Macrofig
Hrm... that's not cool...
I mean, that Stache cares so much about HTML structure. Then again, I know zero about it so...
Curtis Cummings
@ccummings
Stache implements an HTML5 parser to create a DocumentFragment, which is way different than parsing a string to create HTML (like Mustache and EJS)
Patrick Clancy
@patrickclancy
Does Stache support an inline svg? I’m not sure I’m doing this correctly so feel free to point out my errors.
http://jsbin.com/jafali/edit?html,css,output
<svg class="shape-icon">
    <use xlink:href="#shape-icon_back" />
  </svg>
Justin Meyer
@justinbmeyer
@patrickclancy Stache does support SVG
but I'm not sure about all use-cases
avg6003
@avg6003
Patrick Clancy
@patrickclancy

Is it possible to pass (via an attribute) in a deferred object to a component? I can pass a plain object, so my assumption was this would work. But it doesn’t…

<test-component2 my-dfd="{dfd}"></test-component2>

http://jsbin.com/fukocu/edit?html,js,output

dylanrtt
@dylanrtt
@patrickclancy wrapping the deferred in a promise (e.g., Promise.resolve(defObj)) works but you won't be able to resolve it from the child component if that's your use case
Patrick Clancy
@patrickclancy
@dylanrtt interesting… wrapping it in another then’able’ object works. Still feels strange. But that is a solution.
thank you
Justin Meyer
@justinbmeyer
https://github.com/bitovi/canjs/issues/1781#issuecomment-121981031 Thoughts on how to make validations work across components.
Justin Meyer
@justinbmeyer
@DipeshRaichana let me know if you want to talk through those questions.
Justin Meyer
@justinbmeyer
Here's some docs on how you can migrate away from can.Model to can-connect: http://connect.canjs.com/doc/can-connect%7Ccan%7Cmodel.html
Patrick Clancy
@patrickclancy
@dylanrtt Turns out a promise won’t work for me. I’ll see if I can find why passing a deferred fails.
Justin Meyer
@justinbmeyer
@patrickclancy @dylanrtt if passing a promise or deferred doesn't work, can you create an issue?
it certainly seems like a bug
oh, I know what the problem is
this isn't a bug
but an API thing we should fix for 3.0
the problem is that the template isn't rendered until all promises were resolved
this is a hold-over from early JMVC days
before live-binding
Justin Meyer
@justinbmeyer
it works if you do it this way:
avg6003
@avg6003

@justinbmeyer Actually I am using a css class on which I am changing my template using route. Now on the same page when I am switching the template the previuos controller is effecting on my latest temaplte which I have loaded and it is also affected by its own controller too as I have added other controller on the same class. Here is my code.

`define(['can', 'jquery', 'models/DomainModel', 'controllers/FormHeader'], function(can, $, DomainModel, FormHeader) {
'use strict';
var DomainController = can.Control.extend({
defaults: {
view: 'views/domainSearch.hbs'
}
},{
init: function(element, options) {
new FormHeader('#header');
},
'input keyup': function() { ... }
});
return DomainController;
});

I have other login controller but I am calling bothe of them on new LoginController('.main-container');' andnew DomainController('.main-container')`

So when I start to type in login.hbs template the input keyup event automatically getting fired
which is defined in domaincontroller
avg6003
@avg6003
so what should be the solution? Should I use can.Map or can.component?
Patrick Clancy
@patrickclancy
@justinbmeyer Thanks for the help. When I first looked at the jsbin I almost didn’t catch your syntax change to the can.vew. Here it is for anyone looking for this solution.
can.view("app2")({ dfd: defObj });
asavoy
@asavoy
are there any plans to make <can-import> work for non-auto-rendered templates?
Chris Gomez
@akagomez
Huh. I didn’t realize it was meant to only work with auto-rendered templates.
I could swear I used it without auto-render.