पर एक मॉडल पास कर रहा है मैं जेएस और बैकबोन की आवश्यकता के जरिए एंड्रॉइड के लिए एक एप्लीकेशन विकसित कर रहा हूं। मुझे टचेंड इवेंट के माध्यम से राउटर में संग्रह से लिया गया मॉडल पास करना होगा। मैं यह कैसे कर सकता हूं?बैकबोन राउटर
define(["jquery", "underscore","backbone","handlebars", "views/CinemaView", "models/CineDati", "text!templates/listacinema.html"],
function($,_,Backbone,Handlebars,CinemaView, CineDati, template){
var ListaCinemaView = Backbone.View.extend({
template: Handlebars.compile(template),
events: {
"touchend" : "Details"
},
initialize : function(){
var self = this;
$.ajax({
url: 'http://www.cineworld.com/api/quickbook/cinemas',
type: 'GET',
data: {key: 'BwKR7b2D'},
dataType: 'jsonp', // Setting this data type will add the callback parameter for you
success: function (response, status) {
// Check for errors from the server
if (response.errors) {
$.each(response.errors, function() {
alert('An error occurred. Please Try Again');
});
} else {
$.each(response.cinemas, function() {
var cinema = new CineDati();
cinema.set({ id : this.id, name : this.name , cinema_url : this.cinema_url, address: this.address, postcode : this.postcode , telephone : this.telephone });
self.model.add([cinema]);
});
self.render();
}}
});
},
events : {
"#touchend" : Dettagli
},
render : function(){
$(this.el).empty();
$(this.el).html(template).append(
_.each(this.model.models, function (cinema) {
$("#lista").append(new CinemaView({
model: cinema
}).render().el); }, this));
return this;
},
Dettagli : function(){
Backbone.history.navigate(this.model , {trigger: "true"});
}
});
return ListaCinemaView;
});
बहुत बहुत धन्यवाद, आप बहुत मददगार रहे हैं! मैंने पहले से ही marionette.js की जांच की है और मुझे लगता है कि मैं अपने भविष्य के आवेदन के लिए इसका उपयोग करूंगा! :) –
खुशी मैंने मदद की, अगस्तो। आपकी परियोजना के लिए शुभकामनाएं। –
यह समाधान तब खाता नहीं है जब कोई व्यक्ति http: // website/model_id पर पृष्ठ को रीफ्रेश करता है। आप मॉडल का संदर्भ खो देते हैं। –