I am trying to display customer's sale history in a tab. When customer first click in to History tab, the data is displayed from Local Storage of the browser, other wise if the customer search for any specific information, data will gotten from web service(REST) in the form of JSON data.
CustomerView.js
define(["jquery" ,
"underscore" ,
"backbone",
"text!templates/Customer/profile.html",
"text!templates/Quotation/sale.html",
"Quotation"
],function($,_,Backbone,CustomerProfile,SaleHistory,Quotation){
var saleHistory = new Quotation();
var CustomerView = Backbone.View.extend({
initialize: function() {
},
el : "#container",
events : {
'click #searchSaleHistoryButton' : 'searchSaleHistory'
},
'searchSaleHistory' : function(){
var saleHistoryObj = saleHistory.getSaleHistoryByID('877-04');
},
render: function(){
var customerProfile = _.template(CustomerProfile);
$(this.el).html(customerProfile);
}
});
return CustomerView;
});
I want to get saleHistoryObj
to display in sale.html
template instead of history
object get from Local Storage, whenever user click on searchSaleHistoryButton
.
Any suggestions would be appreciated. Thanks.
sale.html
<%
var history = localStorage.getItem("SaleHistory");
var historyLength = history.HistoryData.length;
if(historyLength > 0){
%>
<table class="defaultHisTbl">
<% for(var i = 0; i < historyLength; i++){ %>
<tr>
<td><%= history.HistoryData[i].QuotationNumber%></td>
<td><%= history.HistoryData[i].InvoiceNumber%></td>
<td><%= history.HistoryData[i].QuotationDate%></td>
</tr>
<% } %>
</table>
<% } %>