Yii Framework Forum: How to render partial view on navBar menuItem click? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to render partial view on navBar menuItem click?

#1 User is offline   mozaika 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 30-October 17

Posted 07 December 2017 - 05:45 AM

Hello
I want to render a partial view in my index.php when on NavBar MenuItem is clicked

How should I do that?



Thanks in advance

here is my code
I want to add an event instead of a url....

if (!Yii::$app->user->can('employee')) {
        $menuItems[] = ['label' => Yii::t('app', 'School'), 'url' => ['/school/index']];
        $menuItems[] = ['label' => Yii::t('app', 'Administration'), 'url' => ['/site/contact']];
    }

0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,494
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 07 December 2017 - 06:52 AM

use jquery to to load contents into a div here is an example change your selectors and urls accordingly

$('a[href="/site/contact"]').click(function() {
    $( "#div-id-to-render-in" ).load( "url/to/action" );
});

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users