Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : EJS and @@!!@@

$
0
0
I cam across the same problem. The solution is, you cant use the render function returned by "can.view()" with live-binding. You have to use "can.view()" directly to append the model to the template. Don´t know if thats a bug or design decision.

i had wrote some code like this:
  1. // new requirejs module
  2. // depends on a external ejs file
  3. define(['sometemplate.ejs'], function(template) {

  4.       // register the template, (why i have to do this?)
  5.      can.view.ejs('template_id', template);
  6.       
  7.       // load controller and deliver a template
  8.       // i dont want a template defined inside my controller
  9.       // because i want to reuse the controller with different
  10.       // templates
  11.       var myController = new SomeController('#domid', {
  12.             template: can.view('template_id')
  13.       });
  14. });
Inside my controller i use the template as follow
  1. this.render = function(){

  2.       // render template
  3.       var todom = this.options.template(this.myModel);

  4.       // append
  5.       $("body").html(todom);
  6. }

This works, but only without live binding. If you use a function from the model inside the template you get an "@@!!@@";
You have to submit the model to the "can.view('template_id', myModel)" method. You cant use the render function returned by "can.view()".

Viewing all articles
Browse latest Browse all 3491

Trending Articles