Skip to content

Instantly share code, notes, and snippets.

@rmoura-92
Created July 9, 2013 15:58
Show Gist options
  • Save rmoura-92/5958556 to your computer and use it in GitHub Desktop.
Save rmoura-92/5958556 to your computer and use it in GitHub Desktop.
showEscapadinhaDetalhe: function(id, provider) {
Application.Views.Common.destroy();
Application.Views.Common.startLoading();
var item = Application.Collections.Escapadinhas.get(id);
Application.Views.Escapadinhas.Detalhe = new DetalheView({model:item});
Application.Views.Escapadinhas.SideView = new SideView({model:Application.Collections.Escapadinhas, section:"escapadinhas", id:id});
Application.Views.Escapadinhas.Detalhe.on('reserva', function(e) {
var item = e.model.toJSON();
var pagamento = new PagamentoModel();
pagamento.save({}, {
dataType: 'html',
section: 'escapadinhas',
success: function(response) {
console.log(response);
},
error: function(response) {
console.log(response);
}
});
/*
Application.Views.Escapadinhas.Reserva = new ReservaView({model:item});
Application.Views.Escapadinhas.SideView = new SideDetalheView({model:item});
*/
});
},
define([
'jquery',
'underscore',
'backbone',
'libs/helper',
'text!templates/common/side-results.html',
'text!templates/escapadinhas/side-item.html',
'text!templates/ferias/side-item.html',
'text!templates/hoteis/side-item.html'
], function($, _, Backbone, Helper, TplSideResult, EscapadinhasItem, FeriasItem, HoteisItem){
var SideView = Backbone.View.extend({
el: '#side-nav',
list: '#side-nav .side-list .scroll-wrapper ul',
initialize: function() {
console.log(this);
//this.render();
},
render: function() {
var response = this.model.toJSON();
console.log(response);
$(this.el).html(_.template(TplSideResult));
switch(this.section) {
case 'escapadinhas':
$(this.list).empty().append(_.template(EscapadinhasItem,{results:response, currentId:this.id}));
break;
case 'ferias':
$(this.list).empty().append(_.template(FeriasItem,{results:response, currentId:this.id}));
break;
case 'hoteis':
$(this.list).empty().append(_.template(HoteisItem,{results:response, currentId:this.id}));
break;
}
}
});
return SideView;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment