These are chat archives for canjs/canjs

30th
Nov 2015
Guido Smeets
@gsmeets
Nov 30 2015 10:29
anyone know why this isn't working in a controller:
 "{window} message": function () { }
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 30 2015 10:31
@gsmeets I think because is not processed in can.Control https://github.com/canjs/canjs/blob/master/control/control.js#L322
Guido Smeets
@gsmeets
Nov 30 2015 10:31
ah, cheers, so I'll have to add my own processor for that
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 30 2015 10:32
Yes
Paul Tichonczuk
@tracer99
Nov 30 2015 16:54
How do we insert a script tag into a template? We have to integrate a formstack embeded form into a page. We either get a script tag that doesn't do anything, or we get an error inthe browser saying you can't call document.write on an async call
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 30 2015 16:58
@tracer99 maybe using a helper that returns the script tag string with safeString function works
Paul Tichonczuk
@tracer99
Nov 30 2015 16:58
tried, nope
Chrome outputs this: "Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened."
sadly, the source script we have to insert is just a long list of document.writes
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 30 2015 17:00
even with inline template?
Paul Tichonczuk
@tracer99
Nov 30 2015 17:02
not an inline template, but we're not using components
oh, like devine a var with the template and then insert it that way?
trying
Mohamed Cherif Bouchelaghem
@cherifGsoul
Nov 30 2015 17:03
yes
Ryan Wheale
@DesignByOnyx
Nov 30 2015 18:46
If your script relies on document.write, you will have to overwrite that method to capture all of the writes and manually write it yourself. All of the writes should happen at one time, so something like this should work:
var timer = 0, buffer = "";
function render () {
   var div = document.createElement("div");
   div.innerHTML = buffer;
   document.body.appendChild(div);
   buffer = "";
}
document.write = function (str) {
   clearTimeout(timer);
   buffer += str;
   timer = setTimeout(render, 1);
}
Paul Tichonczuk
@tracer99
Nov 30 2015 18:52
@DesignByOnyx thanks. that looks like it may be the solution
Ryan Wheale
@DesignByOnyx
Nov 30 2015 19:05
Make sure that code happens after the DOM is ready - I didn't test it, but you should be able to find a similar solution out there.
Gerard Finnerty
@halcyonandon
Nov 30 2015 19:39
If I do {{#each some.list}} <some-component value="{{this}}">{{this}}</some-component>{{/each}} no value gets passed to the component in either the attr or via <content/> ... If I do {{this}} this outside of the component it works, the same issue with {{.}} ...has anyone encountered this or knows of a fix/better way
Gerard Finnerty
@halcyonandon
Nov 30 2015 20:53
seems value as an attr works in all cases except when iterating over a list, changing the attr name fixed the issue