define(['jquery', 'underscore', 'backbone', 'text!modules/lastRicette/lastRicetteViewTemplate.html', 'text!modules/lastRicette/lastRicetteItemTemplate.html', 'modules/base/baseView'], function($, _, Backbone, lastRicetteViewTemplate, lastRicetteItemTemplate, BaseView) { var LastRicetteView = BaseView.extend({ collection: null, //initialize template template: _.template(lastRicetteViewTemplate), itemtemplate: _.template(lastRicetteItemTemplate), initialize: function(options) { var self = this; LastRicetteView.__super__.initialize.call(this); this.collection = options.collection; this.collection.fetch({ success: function(data, textStatus, jqXHR) { self.renderItem(); } //success: function(){ self.renderItem(); } }); }, renderItem: function() { var $ul = $('#allRicette'); var items = this.itemtemplate({data: this.collection.toJSON()}); $ul.html(items); $ul.listview("refresh"); $ul.trigger("updatelayout"); $.mobile.loading('hide'); //$( '[data-alpha="true"]' ).alphascroll(); }, //render the content into div of view render: function() { //this.header.title = "pippo"; LastRicetteView.__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()); this.$el.append(this.footer.$el); //return to enable chained calls //this.$el.find("#indexBtn").addClass("ui-btn-active"); return this; } }); return LastRicetteView; });