define(['jquery', 'underscore', 'backbone','text!modules/home/homeViewTemplate.html', 'modules/base/baseView', 'classes/profile', 'classes/utility', 'model/lastRicette/lastRicetteCollection', 'modules/lastricette/lastRicette'], function($, _, Backbone, homeViewTemplate, BaseView, Profile, Utility, LastRicetteCollection, LastRicette ){ var HomeView = BaseView.extend({ //initialize template template:_.template(homeViewTemplate), initialize: function () { HomeView.__super__.initialize.call(this); //this.header.title = "pippo"; }, events: { "click #goFbGroup": "goFbGroup", "click #notifyBtn": "onNotifyBtn" }, goFbGroup: function(){ window.localStorage.setItem("goFbGroup", 1); window.location.href = "https://www.facebook.com/groups/732844273469518/"; }, onNotifyBtn:function(){ var lastricette = new LastRicetteCollection(); // will render home view and navigate to homeView var lastRicetteView=new LastRicette({ collection: lastricette}); //indexView.render(); lastRicetteView.bind('renderCompleted:Categories',Utility.changePage,this); }, onShowed: function() { if(window.localStorage.getItem("goFbGroup") !== "1") this.$el.find("#nuovoGruppo").popup("open"); }, //render the content into div of view render: function(){ //this.header.title = "pippo"; HomeView.__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({ profile: Profile})); this.$el.append(this.footer.$el); this.$el.find("#homeBtn").addClass("ui-btn-active"); var lastNumRicette = Profile.getLastNumRicette(); //if( lastNumRicette > 0) { this.$el.find('#notifyBtn').closest('.ui-btn').show(); this.$el.find('#notifyBtn').addClass("notification"); this.$el.find('.circle').text(12); } //$("#homeBtn").addClass("ui-btn-active"); //return to enable chained calls return this; } }); return HomeView; });