git-svn-id: https://msi/svn/firstRepo/WebClient/branches/Manut_2.2.3@29 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -1,21 +1,30 @@
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/index/indexViewTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, indexViewTemplate, BaseView){
|
||||
define(['jquery', 'underscore', 'backbone','text!modules/index/indexViewTemplate.html','text!modules/index/indexItemViewTemplate.html', 'modules/base/baseView'],
|
||||
function($, _, Backbone, indexViewTemplate, indexItemViewTemplate, BaseView){
|
||||
|
||||
var IndexView = BaseView.extend({
|
||||
|
||||
collection: null,
|
||||
//initialize template
|
||||
template:_.template(indexViewTemplate),
|
||||
templateItem:_.template(indexItemViewTemplate, {variable: 'item'}),
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
success: function(){
|
||||
var $ul = $('#categoryList');
|
||||
var html = "";
|
||||
_.each(self.collection.toJSON(), function(d) {
|
||||
html += self.templateItem(d);
|
||||
});
|
||||
$ul.html(html);
|
||||
//$ul.listview("refresh");
|
||||
//$ul.trigger("updatelayout");
|
||||
//self.trigger("renderCompleted:Categories",self);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//render the content into div of view
|
||||
@@ -26,9 +35,9 @@ define(['jquery', 'underscore', 'backbone','text!modules/index/indexViewTemplate
|
||||
//$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);
|
||||
this.$el.append(this.template());
|
||||
this.$el.append(this.footer.$el);
|
||||
|
||||
//return to enable chained calls
|
||||
this.$el.find("#indexBtn").addClass("ui-btn-active");
|
||||
return this;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<li><a href="#category/<%=item.name%>/<%= item.category_id%>" class="ui-btn ui-btn-icon-right ui-icon-carat-r"><%= item.name %></a></li>
|
||||
@@ -1,9 +1,5 @@
|
||||
<div id="categoryListContent" data-role="content">
|
||||
<h1>Indice</h1>
|
||||
<h1>Indice</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>
|
||||
</ul>
|
||||
</div>
|
||||
Reference in New Issue
Block a user