git-svn-id: https://msi/svn/firstRepo/WebClient/trunk@13 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/index/indexViewTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, indexViewTemplate, BaseView){
|
||||
|
||||
var IndexView = BaseView.extend({
|
||||
|
||||
collection: null,
|
||||
//initialize template
|
||||
template:_.template(indexViewTemplate),
|
||||
|
||||
initialize: function (options) {
|
||||
var self = this;
|
||||
IndexView.__super__.initialize.call(this);
|
||||
this.collection = options.collection;
|
||||
this.collection.fetch({
|
||||
success: function(data, textStatus, jqXHR){
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//render the content into div of view
|
||||
render: function(){
|
||||
//this.header.title = "pippo";
|
||||
IndexView.__super__.render.call(this);
|
||||
//this.el is the root element of Backbone.View. By default, it is a div.
|
||||
//$el is cached jQuery object for the view's element.
|
||||
//append the compiled template into view div container
|
||||
this.$el.append(this.header.$el);
|
||||
this.$el.append(this.template({data:this.collection.toJSON()}));
|
||||
this.$el.append(this.footer.$el);
|
||||
this.trigger("renderCompleted:Categories",this);
|
||||
//return to enable chained calls
|
||||
this.$el.find("#indexBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
}
|
||||
});
|
||||
return IndexView;
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
<div id="categoryListContent" data-role="content">
|
||||
<h1>Indice Ricette</h1>
|
||||
<ul id="categoryList" data-role="listview" data-inset="true">
|
||||
<% for (var i = 0; i < data.length; i++) { %>
|
||||
<% var item = data[i]; %>
|
||||
<li><a href="#category/<%=item.name%>/<%= item.category_id%>" class="ui-btn ui-btn-icon-right ui-icon-carat-r"><%= item.name %></a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
Reference in New Issue
Block a user