finnsson / pagerjs

The Single Page Application Framework for KnockoutJS
http://pagerjs.com/
MIT License
271 stars 68 forks source link

Multiple active pages #216

Open ramvis-imx opened 9 years ago

ramvis-imx commented 9 years ago

Hello guys!

We have quite a big single page application. The problem is that sometimes Pager sets multiple pages as active. This can be reproduced when using sourceOnShow property in all pages and very quickly hitting menu items in the same level (without letting pages to load completely).

Because asynchronous callbacks Pager sometimes sets page as visible when it is no longer visible. For example when hitting a menu item, sourceOnShow request is made to server. At that moment we hit another menu item. Another sourceOnShow request is made to server. Now we have second menu item visible (active in the menu). But first sourceOnShow response from server arrives, Pager adds its HTML elements to DOM, creates bindings and founds another page with sourceOnShow and role=start in it. Creates third sourceOnShow request to server and when it is received and added to DOM, pager set a page as visible even if I have already navigated to another menu item.

The problem is that library do not check whether page's parent is active (or no more active) before showing it.

Simple check solves a problem.

image

Hope you add this fix to library and we will be able to continue use official version of your library. Thanks!