locked
Sammy.js with AspNet MVC is slow RRS feed

  • Question

  • User-1350042179 posted

    Hi

    I integrated knockout .. sammy.js with ASPNET MVC, but I see that sometimes the routes are very slow,,,

    I created routes as:

       this.get('#EmpresasCer', function () {
                    self.GoToModule({ viewName: 'EmpresaCer/EmpresaCerBusqueda', viewModelName: 'EmpresaCerBusqueda', replaceLast: true });
                });

    And they call the function..

     self.GoToModule = function (moduleInfo) {
    
                if (typeof tinyMCE !== 'undefined') {
                    tinyMCE.remove();
                }
    
                var focusTab = function (tabId) {
                    ko.utils.arrayForEach(self.ApplicationTabs(), function (val) {
                        val.Activo(val.TabId === tabId);
                    });
                };
           
                var setTab = function () {
                    var fullViewUrl = setAjaxUrl(moduleInfo.viewName);
                    require(['knockout', 'text!' + fullViewUrl, moduleInfo.viewModelName], function (ko, text, viewModel) {
                        var $html = $(text);
                        ko.applyBindings(new viewModel(moduleInfo.params), $html[0]);
                        var newId = createUUID();
                        self.ApplicationTabs.push({
                            TabId: newId,
                            ViewName: moduleInfo.ViewName,
                            ViewModelName: moduleInfo.viewModelName,
                            ReplaceLast: moduleInfo.replaceLast,
                            PromptExit: moduleInfo.promptExit,
                            Activo: ko.observable(true)
                        });
                        if (moduleInfo.promptExit) {
                            setLocalStorageVariable("KeepCurrentPage", "true");
                        }
    
                        $('#' + newId).html($html);
                        focusTab(newId);
                    }, setRequireError);
                };
                var currentTab = ko.utils.arrayFirst(self.ApplicationTabs(), function (val) {
                    return val.ViewModelName === moduleInfo.viewModelName;
                });
                if (currentTab !== null) {
                    if (moduleInfo.replaceLast) {
                        self.ApplicationTabs.remove(currentTab);
                        setTab();
                    }
                    focusTab(currentTab.TabId);
                } else {
                    setTab();
                }
                //content.setPage(viewModelName, viewName, params);                               			
            };   

    I dont' understand why sometimes...  when I click in the link:::

    <a href="#" title="Directorio Empresa" data-bind="click: GotToHash.bind($data,  'EmpresasCer', null)">Directorio Empresa</a>

    It can not find the route..

     this.get('#EmpresasCer', function () {
                    self.GoToModule({ viewName: 'EmpresaCer/EmpresaCerBusqueda', viewModelName: 'EmpresaCerBusqueda', replaceLast: true });
                });

    Tuesday, July 16, 2019 4:33 AM

All replies

  • User197322208 posted

    It can not find the route..

    What is the route and what is the specific message that the browser shows ?

    And the problem is that 

    routes are very slow
    or that it does not find the route?

    Tuesday, July 16, 2019 5:48 AM
  • User-1350042179 posted
    Hi
    The problem is that sometimes the app doesn't find the route.
    Tuesday, July 16, 2019 1:34 PM
  • User1520731567 posted

    Hi GotToHash,

    What is your error message?

    Could you please post more explanation so that I can understand what your mean.

    Best Regards.

    Yuki Tao

    Wednesday, July 17, 2019 8:11 AM
  • User-1350042179 posted

    The problem is that sometimes when I want to enter in a link, I have to wait 3 seconds before I could enter..

    For instance...

    I have to wait 3 seconds before I could enter in "Directorio Empresa", although I clicked on the link.

    Saturday, July 20, 2019 11:00 PM
  • User1520731567 posted

    Hi GotToHash,

    I suggest you could try to use F12 develop tool to troubleshoot the performance.

    And you could refer to this article:

    https://developers.google.com/web/tools/chrome-devtools/rendering-tools/

    Best Regards.

    Yuki Tao

    Tuesday, July 23, 2019 9:25 AM