2

This is an example of the problem: widget is not reinitialized on subsequent requests

I have a "pager" widget. The first time I navigate to a page where it is used, ctor is executed and the pager is initialized (page 1).

Now let say I navigate to page 6.

The problem is when I navigate to another page and then back to the page where the pager is, the pager (widget) is still rendered with page 6 selected and ctor is not executed. The widget controller is not a singleton.

Is there something I don't get?

4

1 回答 1

0

由于页面没有被重新渲染(所以小部件),小部件的任何生命周期回调都不会被调用。您可以通过它与父页面的激活方法中的小部件进行通信

  1. 从小部件侦听的根页面的激活方法引发事件
  2. 更新一些可观察到的小部件订阅的数据
  3. 或者,肮脏的方式 - 不要这样做,只需通过使用 with/if 绑定包装小部件来重新呈现小部件,这将随着每个激活方法调用而改变。如果您无法更改小部件代码,这可能会有所帮助,这不太可能。
于 2013-10-02T13:20:58.440 回答