MENU : Click on a link => How to reload only the content part of the page and not the whole page ?

Dear Support,


I use this menu on my website : https://ej2.syncfusion.com/vue/demos/samples/sidebar/sidebar-menu/index.html

However, I have a problem :  When I click on a link of the menu, it reloads all the page, instead of reloading only the content part.
My links are defined in each "url" attribute of the menuItems.

I juste want the "content" part to be reloaded, not the entire page, like the menu on your on website : https://ej2.syncfusion.com/home/index.html#platform
=> When you click on "javascript", "angular" (etc), it reloads only the content. This is exactly what I would like.

Can you help me ? 

My code is in the AppLayout.txt file.
Thank you in advance.





Attachment: AppLayout_443a7ae6.zip

5 Replies

AS Aravinthan Seetharaman Syncfusion Team July 7, 2021 04:06 AM UTC

Hi Sandra, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. We need to validate more on your query. So, we will update further details, on 8th July 2021. We appreciate your patience until then. 
 
Regards, 
Aravinthan S 



AS Aravinthan Seetharaman Syncfusion Team July 9, 2021 03:21 PM UTC

Hi Sandra, 
 
Thanks for the patience. 
 
We have validated your requirement. We can able to achieve your requirement by using template in MenuBar. Please refer the below code snippet and sample. 
 
App.vue 
 
<template> 
    <div class="template-menu-control"> 
        <ejs-menu :items="data" :fields="menuFields" :template="menuTemplate"></ejs-menu> 
         <div id="app"> 
    <router-view></router-view> 
  </div> 
    </div> 
     
</template> 
 
<script> 
import Vue from "vue"; 
import { MenuPlugin } from "@syncfusion/ej2-vue-navigations"; 
 
Vue.use(MenuPlugin); 
 
export default { 
  data: function() { 
    var menutemplateVue = Vue.component("demo", { 
    template: '  <span v-if="data.category"> {{data.category}} </span>'+ 
    ' <div v-else-if="data.value" style="width: 100%;display: flex;justify-content: space-between;">'+ 
       '<router-link :to="data.url" exact tag="li"><a class="e-menu-url">{{data.value}}</a></router-link></div>' + 
    '<span class="e-menu-template" v-else-if="data.support">'+ 
        '<ul>'+ 
        '<li v-bind:key="index" v-for="(val,index) of data.support">'+ 
        ' {{val.value}} ' + 
            '<span v-if="val.count" class="e-badge e-badge-success">{{val.count}}</span> '+ 
        ' </li> '+ 
        '</ul>'+ 
    '</span>', 
    data() { 
        return { 
        data: {} 
        } 
    } 
    }); 
 
    return { 
        data: [ 
            { 
                category: 'Products', 
                options: [ 
                    { value: 'JavaScript', url: 'javascript' }, 
                    { value: 'Angular', url: 'angular' }, 
                    { value: 'ASP.NET Core', url: 'core' }, 
                    { value: 'ASP.NET MVC', url: 'mvc' } 
                ] 
            }, 
            { 
                category: 'Services', 
                options: [ 
                    { 
                        support: [ 
                            { value: 'Application Development', count: '1200+' },                        ] 
                    } 
                ] 
            }, 
            { category: 'Careers' }, 
            { category: 'Sign In' } 
        ], 
        menuFields: { 
            text: ['category', 'value'], 
            children: ['options'] 
        }, 
        menuTemplate: function () { 
            return { 
                template : menutemplateVue 
            } 
        } 
    }; 
  } 
} 
 
For your convenience we have prepared sample that can be found here. 
 
 
Could you please check the above details, and get back to us, if you need assistance on this. 
 
Regards, 
Aravinthan S 



SB Sandra Bordier July 17, 2021 01:30 PM UTC

Thank you for your reply.

I am sorry but I don't understand your sample zip file at all, because it is very different from your sample just above.


For instance, in the App.vue file you have

"id="querybuilder" ref="querybuilder"



1 /==> What is ejs-query-builder ? What is it used for and why is it needed for this menu ?

​I am pretty lost, because the code in your sample zip file does not look like the initial demo code at all, and there is no querybuilder in it : https://ej2.syncfusion.com/vue/demos/#/material/sidebar/sidebar-menu.html



So what is the good code ? What should I use ? The example above of your sample.zip file ?

Moreover, I don't understand this part in your example above :

" "

2/ => How does router-view work ?
It doesn't seem to be declared anywhere.

3/ I tried to copy your code and install the querybuilder packaage (even though I don't get how it works) and got the following warnings :

WARNING in ./node_modules/@syncfusion/ej2-vue-querybuilder/node_modules/vue-class-component/dist/vue-class-component.esm-bundler.js 387:27-30

export 'ref' (imported as 'ref') was not found in 'vue' (possible exports: default)


WARNING in ./node_modules/@syncfusion/ej2-vue-querybuilder/node_modules/vue-class-component/dist/vue-class-component.esm-bundler.js 402:35-44

export 'proxyRefs' (imported as 'proxyRefs') was not found in 'vue' (possible exports: default)


WARNING in ./node_modules/@syncfusion/ej2-vue-querybuilder/node_modules/vue-class-component/dist/vue-class-component.esm-bundler.js 407:31-40

export 'proxyRefs' (imported as 'proxyRefs') was not found in 'vue' (possible exports: default)


==> Can you please explain me what is it about, and how can I remove theses warnings ?

Anyway it doesn't work I have many errors and no menu on my page :( 

PICTURE LINK

4/ Instead of the sample.zip file, can you please share a complete online sample , with everything needed included (ejs-menu, router-view and so on)? This is really easier to check if the code works well.
I mean an online sample like this one for stance : https://codesandbox.io/s/form-validation-forked-2263r?file=/src/App.vue


Best regards :)



SB Sandra Bordier July 17, 2021 02:23 PM UTC

PS :  I joined my AppLayout code where I tried to make it as your sample above.
However I guess I have some problems with the data  [category ] part and the menuTemplate part because id dos not work I can't see the menu


Best regards :)


Attachment: layout_f8df9677.zip


AS Aravinthan Seetharaman Syncfusion Team July 20, 2021 03:58 AM UTC

 
Sorry for the inconvenience caused. 
 
Please ignore the previous update. 
 
We have validated your requirement. We can able to achieve your requirement by using template in Menu. For your convenience we have prepared video demo here. Please refer the demo, code snippet and sample given below. 
 
 
main.js 
import Vue from 'vue' 
import App from './App.vue' 
import Router from "vue-router"; 
import router from './router' 
Vue.use(Router); 
new Vue({ 
  router, 
  el: '#app', 
  render: h => h(App), 
 
}) 
 
 
router.js 
 
import Vue from 'vue' 
import VueRouter from 'vue-router' 
import Home from './Home' 
import Core from './Core' 
import Mvc from './Mvc' 
import Javascript from './Javascript' 
import Angular from './Angular' 
 
Vue.use(VueRouter) 
 
const routes = [ 
    { path: '/', component: Home }, 
    { path: '/core', component: Core }, 
    { path: '/angular', component: Angular}, 
    { path: '/mvc', component: Mvc}, 
    { path: '/javascript', component: Javascript} 
] 
export default new VueRouter({ 
    routes, 
    mode: 'history', 
}) 
 
 
App.vue 
 
<template> 
    <div class="template-menu-control"> 
        <ejs-menu :items="data" :fields="menuFields" :template="menuTemplate"></ejs-menu> 
         <div id="app"> 
    <router-view></router-view> 
  </div> 
    </div> 
     
</template> 
 
<script> 
import Vue from "vue"; 
import { MenuPlugin } from "@syncfusion/ej2-vue-navigations"; 
 
Vue.use(MenuPlugin); 
 
export default { 
  data: function() { 
    var menutemplateVue = Vue.component("demo", { 
    template: '  <span v-if="data.category"> {{data.category}} </span>'+ 
    ' <div v-else-if="data.value" style="width: 100%;display: flex;justify-content: space-between;">'+ 
       '<router-link :to="data.url" exact tag="li"><a class="e-menu-url">{{data.value}}</a></router-link></div>' + 
    '<span class="e-menu-template" v-else-if="data.support">'+ 
        '<ul>'+ 
        '<li v-bind:key="index" v-for="(val,index) of data.support">'+ 
        ' {{val.value}} ' + 
            '<span v-if="val.count" class="e-badge e-badge-success">{{val.count}}</span> '+ 
        ' </li> '+ 
        '</ul>'+ 
    '</span>', 
    data() { 
        return { 
        data: {} 
        } 
    } 
    }); 
 
    return { 
        data: [ 
            { 
                category: 'Products', 
                options: [ 
                    { value: 'JavaScript', url: 'javascript' }, 
                    { value: 'Angular', url: 'angular' }, 
                    { value: 'ASP.NET Core', url: 'core' }, 
                    { value: 'ASP.NET MVC', url: 'mvc' } 
                ] 
            }, 
            { 
                category: 'Services', 
                options: [ 
                    { 
                        support: [ 
                            { value: 'Application Development', count: '1200+' }, 
                            { value: 'Maintenance & Support', count: '3700+' }, 
                            { value: 'Quality Assurance' }, 
                            { value: 'Cloud Integration', count: '900+' } 
                        ] 
                    } 
                ] 
            }, 
            { category: 'Careers' }, 
            { category: 'Sign In' } 
        ], 
        menuFields: { 
            text: ['category', 'value'], 
            children: ['options'] 
        }, 
        menuTemplate: function () { 
            return { 
                template : menutemplateVue 
            } 
        } 
    }; 
  } 
} 
</script> 
 
 
 
To run the sample please follow the below steps. 
 
1.Extract the attachments from above Sample link. 
2.Open the quickstart folder in command prompt 
3.Give command npm install 
 
 
4. After npm installed, give command npm run dev 
 
 
 
 
5. Sample page will open in new tab in default Browser. 
 
 
Could you please check the above details and get back to us, if you need assistance on this. 
 
Regards, 
Aravinthan S

Loader.
Up arrow icon