unplugged / unplugged-controls

7 stars 9 forks source link

unpComputedNavigator - add a 'state' property to menu items? #489

Closed MartinPerrie closed 10 years ago

MartinPerrie commented 10 years ago

I'm using the computed navigator to provide access to a set of views. Each view lists a different document type. In most cases documents are opened via ajax. In this case, when viewing a document, the navigator still shows the relevant entry highlighted.

There is one exception where documents are opened from a view using a full page load so that the tabbed footer can be used, just for that document type. In this case the navigator does not show a highlighted entry and this looks a bit inconsistent.

To workaround this I added an extra property to one menu item on the navigator 'state: Active' and altered the custom control to check for this when computing the style class on all 3 levels of menu item, e.g.

xp:this.styleClass<![CDATA[#{javascript:if (("/" + getCurrentXPage()) == menuItem.page || menuItem.state == "Active"){ return "topopen active"; }}]]>/xp:this.styleClass

Is there a better way to achieve this?

whitemx commented 10 years ago

At the moment what you've done is about the best way to achieve what you're after. I can add that into the main controls in the next release.