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

EJS BUG looses observableness using canJS

$
0
0
Trying to replicate this in js fiddlle would take forever. I have lots of api's and this is a view 3 levels deep.

But this is the view:

  1. <ul class="nav nav-pills navtabs">
  2. <%
  3. var order = this.Order;
  4. console.log(order);
  5.  $.each(this.MerchantOrders, function(i, mo){
  6. %><li class=" <%= ((i==0)? 'active' :'' ) %> "><a data-toggle="tab" href="#merchant-order<%= mo.MerchantOrder.id %>"> <%= mo.Merchant.name %></a></li><%
  7.  });
  8.  console.log(order);
  9.  %><%
  10.  console.log(order);
  11. %>

  12. </ul>

  13. <%= console.log(order); %>
  14. <div class="tab-content">
  15. <%
  16. console.log("loop start");
  17. console.log(order);
  18. $.each(this.MerchantOrders, function(i, mo){
  19. %><div id='merchant-order<%=mo.MerchantOrder.id%>' class='tab-pane <%= ((i==0) ? 'active' : '' ) %> merchant-order mo-<%=mo.MerchantOrder.id%>'><%== can.view.render('//manager/modules/orders/views/merchant_order', mo)%></div><%
  20. });
  21. %>
  22. </div>

This is the console output
  1. Constructor {_data: Object, _cid: ".observe3", id: "10773", user_id: "31", completed: null…} manager_modules_orders_views_merchant_orders_ejs.js:3
  2. Constructor {_data: Object, _cid: ".observe3", id: "10773", user_id: "31", completed: null…}  manager_modules_orders_views_merchant_orders_ejs.js:7
  3. Object {Order: Object, User: Object, OrderApprovalCode: Object, MerchantOrder: Array[3], OrderDeal: Array[2]…}  manager_modules_orders_views_merchant_orders_ejs.js:10
  4. Object {Order: Object, User: Object, OrderApprovalCode: Object, MerchantOrder: Array[3], OrderDeal: Array[2]…}  manager_modules_orders_views_merchant_orders_ejs.js:11
  5. loop start manager_modules_orders_views_merchant_orders_ejs.js:12
  6. Object {Order: Object, User: Object, OrderApprovalCode: Object, MerchantOrder: Array[3], OrderDeal: Array[2]…}  manager_modules_orders_views_merchant_orders_ejs.js:13
You will notice that after the second console.log()  *(the one that happens on line 10 of the and is output on line 3 of the console section).

All of the  "Constructor" turn into an "Object".

I have played with it and it seems to have to do with opening and closing of the magic tags. <%%>

Because if i moved the 3rd console.log up into the first set of <%%>  just above line 8, the "order" object would be a "Constructor" not an "Object" 

Viewing all articles
Browse latest Browse all 3491

Trending Articles