0

在使用 Backbone 同步加载一些数据之前,我正在显示一个通知;通知未显示。仅当我在通知调用之后放置断点时才显示!

代码如下所示:

PM.notify($.i18n.prop('loading_project'));

PM.project = new PM.Project({id: id});
PM.project.fetch({async:false});
PM.projects[id] = PM.project;
;;; other async calls follows but are not included here to save space...

PM.notify = function(text) {
$('.notification-area').prepend('<ul class="thankyou pm-thankyou"><li class="notification">{0}</li></ul>'.format(text));
}

我尝试将异步设置为 true,它会导致显示通知,但是在这种情况下我不希望执行异步调用。

有任何想法吗?

4

1 回答 1

0

当你在 notify() 之后设置断点时,应用程序会停在那里,并且有足够的时间来获取数据,然后调用 notify()。这意味着断点实际上使这些代码是异步的。

我很有趣,为什么您不希望在这里进行异步调用。我认为这就是重点。

于 2013-05-16T10:06:42.290 回答