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

View rendering problems upgrading to v3.3

$
0
0
Hi,

I'm trying to upgrade my app from v   to v3.3, but I'm running into quite a few problems around view rendering.

As an example, here's one of my ejs templates:

<div class="im-variable variabletype-<%= this.type %>" style="position: absolute; left: <%=this.canvasLeft  + "px" %>; top: <%=this.canvasTop  + "px" %>;" data-variableid="<%=this.id%>" title="<%=this.name%>: Click to edit">
  <span class="imicon icon-<%=this.icon%>">&nbsp;</span>  
  <div class="variable-name">
 <%=this.name%>
  </div>
</div>

This was originally rendered with this line of code:

var updatedElt = $($.View("//tools/im/variable/list/views/variable.ejs", updatedVariable));

Now, the code doesn't seem to work if I replace that with 

var updatedElt = can.view("//tools/im/variable/list/views/variable.ejs", updatedVariable);

Because my code then does some stuff that assumes updatedElt is a jQuery object rather than a documentFragment. So I tried this instead as a stopgap (my goal is to port to v3.3 with minimal changes then work on moving to use some of the improvements/new stuff once that's done):

var updatedElt = $(can.view.render("//tools/im/variable/list/views/variable.ejs", updatedVariable));

But I get this as the result:

<span class="imicon icon-fee" data-view-id="141">&nbsp;</span>  
  <div class="variable-name">
 Breakages
  </div>
</span>

As you can see by comparing this with the original template, I'm losing a whole bunch of stuff from the template - it's just not getting rendered - plus I'm getting this additional data-view-id attribute.

Can anyone suggest what I'm doing wrong? Please bear in mind that I'm looking for the lowest impact upgrade path to start with so I just need to find whatever I should call in canjs that does exactly the same as the old $.View call did.

Thanks in advance
Jon

Viewing all articles
Browse latest Browse all 3491

Trending Articles