Anchor in Nav Widget

I’m using the jquery plug-in scrolling-nav from James Wilson to fluently scroll between menu items. To do this it uses anchor/name attributes.

The problem with the Nav::widget provided in Yii2 is that I can’t get it working. The anchor links has to be accessible form any other page. But the page must NOT refresh when the user is already watching the page, it just has the scroll to the anchor.

I tried some variation in the links form the dropdown menu.


        ['label' => 'Diensten', 'items' => [

            ['label' => 'Hosting', 'url' => ['site/diensten#hosting'],'linkOptions'=>['class'=>'page-scroll']],

            ['label' => 'Camerawerk', 'url' => ['site/diensten#camerawerk'],'linkOptions'=>['class'=>'page-scroll']],

            ['label' => 'DJ', 'url' => '#dj','linkOptions'=>['class'=>'page-scroll']],

            ]

        ],



The first 2 links (hosting + Camerawerk) are working form any page. It will not fluently scroll the page when the user already is on the page, it just refreshes the page.

The DJ link is scrolling like expected but it doesn’t load the correct page outside the “diensten” page because there is only an anchor.