Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling variable in template from view of backbone
    text
    copied!<p>I'm using <code>text! plug-in</code> of require.js to load javascript templates of my backbone project.</p> <p>Here it is :</p> <pre><code>&lt;table id="showcart"&gt; &lt;tr&gt;&lt;td class="cartitemhead"&gt;Item to buy&lt;/td&gt;&lt;td class="cartitemhead" style="text-align: center;"&gt;Quantity&lt;/td&gt;&lt;/tr&gt; &lt;% _.each(item, function(item) { %&gt; &lt;tr&gt;&lt;td&gt;&lt;table class="verticallist"&gt;&lt;tr&gt;&lt;td rowspan="4" style="width: 120px;"&gt;&lt;img src="&lt;%=item.PictureName%&gt;" alt="Product" width="95px"/&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;&lt;%=trimString(item.Name,50)%&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;Available in Stock(s)!&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;i&gt;Rating: 650Va-390w Input: Single&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;td class="centertxt"&gt;&lt;%=item.QuantityInCart%&gt;&lt;/td&gt;&lt;/tr&gt; &lt;% }); %&gt; &lt;/table&gt; </code></pre> <p><code>item</code> variable was declared in my view. </p> <pre><code>var CartListView = Backbone.View.extend({ render: function(){ var item = deserializeJSONToObj(window.localStorage.getItem("Cart")); var cartList = _.template(showCartTemplate, {}) $("#cartlist").html(cartList); } }); </code></pre> <p>Model : </p> <pre><code>define(["underscore" , "backbone"],function(_ , Backbone){ var Cart = Backbone.Model.extend({ }); }); </code></pre> <p>I got one error from console : <code>Uncaught ReferenceError: item is not defined</code>.</p> <p>Any help would be much appreciated, thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload