event-handlingcanjscanjs-component

'inserted' event not fired for Component (CanJS, JSFiddle)


For some reason the inserted event is not fired for any component in my set-up in this fiddle.

I'm trying to play with view bindings here, but the basic (hard coded) data aren't produced and used at all. No console.log line of a callback of an inserted-event appears, therefore I think, that this event isn't fired. But the keyup-event on the input element is interestingly fired.

Am I missing any can library (from a CDN) here? Any other idea?


Solution

  • can.stache returns a renderer function, so you need to call it in order to correctly create a document fragment.

    I think changing this: $('#can-bindings').append(can.stache('<search-comp />'));

    to: $('#can-bindings').append(can.stache('<search-comp />')());

    in each of the places where you're trying to render templates should solve your problem.