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:
- <ul class="nav nav-pills navtabs">
- <%
- var order = this.Order;
- console.log(order);
- $.each(this.MerchantOrders, function(i, mo){
- %><li class=" <%= ((i==0)? 'active' :'' ) %> "><a data-toggle="tab" href="#merchant-order<%= mo.MerchantOrder.id %>"> <%= mo.Merchant.name %></a></li><%
- });
- console.log(order);
- %><%
- console.log(order);
- %>
- </ul>
- <%= console.log(order); %>
- <div class="tab-content">
- <%
- console.log("loop start");
- console.log(order);
- $.each(this.MerchantOrders, function(i, mo){
- %><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><%
- });
- %>
- </div>
This is the console output
- Constructor {_data: Object, _cid: ".observe3", id: "10773", user_id: "31", completed: null…} manager_modules_orders_views_merchant_orders_ejs.js:3
- Constructor {_data: Object, _cid: ".observe3", id: "10773", user_id: "31", completed: null…} manager_modules_orders_views_merchant_orders_ejs.js:7
- Object {Order: Object, User: Object, OrderApprovalCode: Object, MerchantOrder: Array[3], OrderDeal: Array[2]…} manager_modules_orders_views_merchant_orders_ejs.js:10
- Object {Order: Object, User: Object, OrderApprovalCode: Object, MerchantOrder: Array[3], OrderDeal: Array[2]…} manager_modules_orders_views_merchant_orders_ejs.js:11
- loop start manager_modules_orders_views_merchant_orders_ejs.js:12
- 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"