Questo mi confonde davvero, penso di essere stupido ma ho cercato e ho fatto tutto ciò che potevo. Ogni volta che dichiaro una vista ed eseguo il test BDD con gelsomino, restituisce sempre "indefinito non è una funzione". Questo è un codicevista backbone - non è definito
window.LocationView = Backbone.View.extend({
initialize: function() {
// create new marker first
this.marker = new google.maps.Marker({
title: this.model.get('name'),
draggable: true,
animation: google.maps.Animation.DROP,
position: new google.maps.LatLng(this.model.get('lat'), this.model.get('long')), // give the position here
});
// bind events
this.model.bind('change', this.render, this);
},
render: function() {
this.marker.setTitle(this.model.get("name"));
this.marker.setPosition(new google.maps.LatLng(this.model.get('lat'), this.model.get('long')));
},
});
Ecco come ho dichiarato che:
this.view = new LocationView({model: this.location});
this.view = new LocationView();
// neither of these ones work.
Questo è l'errore quando ho eseguito questo codice con il gelsomino:
TypeError: undefined is not a function
at [object Object].make (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:29:37)
at [object Object]._ensureElement (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:30:270)
at [object Object].<anonymous> (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:28:127)
at new <anonymous> (http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js:32:136)
at [object Object].<anonymous> (http://localhost/gmap_api/public/test/spec/specs.js:62:21)
at [object Object].execute (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1001:15)
at [object Object].next_ (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1790:31)
at [object Object].start (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1743:8)
at [object Object].execute (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:2070:14)
at [object Object].next_ (http://localhost/gmap_api/public/test/spec/jasmine/jasmine.js:1790:31)
Non sono sicuro di cosa significhi "dichiarare una vista e quindi dichiarare una nuova vista". Stai istanziando un LocationView e poi un secondo LocationView? Il primo va bene, ma il secondo no? Oppure 'il nuovo LocationView ({model: this.location})' funziona ma 'new LocationView();' no? –
@muistooshort: Ci scusiamo per il cattivo inglese, ho risolto il problema. Significa che mi viene richiesto LocationView non è definito ogni volta, anche se l'ho dichiarato ?? – nXqd