当我在事件监听器中时,如何访问对象的成员?这是一个例子,我认为这更容易理解;)
MapProvider = function(mapID, autocompleteID) {
// some other members
MapProvider.prototype.map = null;
MapProvider.prototype.autocomplete = null;
// init function
MapProvider.prototype.initAutocomplete = function() {
// some other stuff and now i create an autocompleteObj
this.autocomplete = new google.maps.places.Autocomplete(this.inputField, myOptions);
this.autocomplete.bindTo('bounds', this.map);
// until now everything went fine
// now i want to listen to the autocompleteObj
// the handler is working fine aswell
google.maps.event.addListener(this.autocomplete, 'place_changed', function() {
// but now i want to acces the autocompleteObj again, but i cant :(
// how can i access my members that i deklared in my first lines ?
console.log(this.autocomplete.getPlace());
});
}
谢谢 :)