가 나는 장치의 위치를 결정하기 위해 노력하고 응답 모델을 설정하고가 설정할 수 없습니다 모델 - 백본
class FoursquareSearch.Views.Origin extends Backbone.View
events:
'change [name=origin]': 'setOrigin'
'click [name=geolocate]' : 'geolocate'
geolocate: ->
navigator.geolocation.getCurrentPosition(@handle)
handle: (response) ->
@model.set(coords: response)
뷰가 있습니다. 그러나 나는 얻는다
Uncaught TypeError: Cannot call method 'set' of undefined
이상한 물건은 이것의 내부의이 기능 만이 일어난다. 작동 같은 내부보기
geocode: (location) ->
data =
location: location
$.ajax(
type: 'POST'
url: '/search/geocode'
data: data
dataType: 'json'
error: (jqXHR, textStatus, errorThrown) =>
alert("ERROR")
success: (response, text, xhr) =>
@model.set(coords: response)
@center(@model.get('coords'))
)
을, 그리고 그것을 잘 작동합니다 ... 난 그냥 모델을 설정하는 다른 기능을 얻을 수 그러나 예를 들어 내가 사용하는 경우. 나는 이것이 비동기적인 것에 관한 것이라고 생각한다. 나는 결코 이것에 전문가가 아니다, 내가가는 것에 따라 나는 백본을 집어 들고있다. 그러나 이것은 나를 비틀 거리고있다!
정말 고맙습니다. –