Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #101670
    Dark Beccio

    Hi, when loading sub pages from my smart.router path list javascript is loaded only the first time, second time i go in that page i get only html.
    Problem is i can not use window.onload on sub pages.
    Is there any other event i can use?
    if not , what is the correct way to build router sub pages ?


    Hi Dark Beccio,
    Take my apologies for the late reply.
    You can use the templateApplied setting of the Smart.Router and with it you can run the javascript each time the template is applied.
    I have made a little code snippet on how to achieve this:
    //In your JS file

    window.onload = function () {
        const router = new JQX.Router('mainView', './');
            { path: '/', template: 'homeTemplate', title: 'Home' },
            { path: '/about', template: 'aboutTemplate', title: 'About',},
            { path: '/contacts', template: 'contactsTemplate', title: 'Contacts' }
        router.templateApplied = viewChanged;
        function viewChanged(route) {
        const path = route.path;
            if (path == '/about'){
                alert('The route is: '+ path)

    Note that for base for this code snippet I have used the example from the documentation about the Router.
    Here is a link for it:
    Please, do not hesitate to contact us if you have any additional questions.
    Best regards,
    Yavor Dashev
    Smart UI Team

    Dark Beccio

    Don’t worry, i made consulting with u’r  <span lang=”en”>Colleagues and we solved the problems =)</span>

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.