我在使用以下代码段时遇到问题。我的 init 方法需要运行并完成 getLocation() 函数,然后 initializeMapp() 和 geoListen() 才能运行。我将 rsvp.js 链接为资源,但不太确定如何实现。我还尝试了 jQuery $when.done 方法。任何帮助表示赞赏。
jQuery方法:
//initial page load method
function init() {
//get user location then builds map and listens to database
$.when(getLocation()).done.(function () {
//build map now that you have user location
initializeMap();
//Starts listening to database changes
geoListen();
})
}
回复方式:
//initial page load method
function init() {
//get user location then builds map and listens to database
getLocation().then(function () {
//build map now that you have user location
initializeMap();
//Starts listening to database changes
geoListen();
})
}