0

我在 jsmvc 的主目录上收听$.route.delegate('someparam', ...),当它被触发时,我决定加载哪个控制器,并删除旧控制器(如果可用),这个问题我也使用$ .route.delegate('some-other-param')在控制器中,问题是当控制器被销毁时,它会尝试 $.router.undelegate('some-other-param') 导致错误:

    **delegate is undefined:**
file: delegate.js
73:    if(event.batchNum && delegate.batchNum === event.batchNum){

到目前为止,我可以在代码中看到,问题是因为我在查询委托的 for 循环内调用取消委托。

// for each delegate
            for(var i =0; i < len; i++){

有没有办法避免这个问题?

4

1 回答 1

0

I couldn't find a way to do this, in the end i used bind for the 'someparam' (which is the outer listener) and delegate for 'some-other-param' which is the inner.

That is a workaround for the delete is undefined error.

于 2012-10-22T16:26:22.153 回答