Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use href tag with option reload?
Message
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
How to use href tag with option reload?
Divers
Thread ID:
01625913
Message ID:
01625913
Vues:
40
Hi everybody,

I'm having this problem. In our menu view we have the following code:
<ul>
                                @foreach (var child in parent.Children)
                                {
                                    <li class="@MenuHelper.SetChildClass(child, ViewBag) childNode">
                                        <a href="@child.NavigateUrl">@child.Text</a>
                                    </li>
                                }
                            </ul>
Now, we also have an ability to add items to the Favorites menu. All that nice code was developed by my colleague.

And I'll try to describe the problem. We have a few forms that only consist of a single page. Here is one example of such page (I'm showing all the js code for the controller of that page):
(function () {
    'use strict';

    var app = angular.module('sysMgrApp');

    app.config(['$stateProvider',function($stateProvider) {
        $stateProvider.state('home', {
            url: '/',
            template: ''
        }).
        state('edit', {
            url: '/edit/:id',
            controller: 'prefsSlsCrudController',
            templateUrl: 'AccountingAudit/prefsSls/index'
        }).state('new', {
            url: '/new',
            controller: 'prefsSlsCrudController',
            templateUrl: 'AccountingAudit/prefsSls/index'
        });
    }]);

    app.controller('prefsSlsSearchController',
        ['$scope', '$rootScope', '$timeout', '$state', 'prefsSlsService', 'resourceFactory',
        function ($scope, $rootScope, $timeout, $state, prefsSlsService, resourceFactory) {

            var init = function () {
                $scope.isEditLoading = true;
                $scope.disableAction = false;
                $scope.showForm = false;
                doSearch();
            };            

            var doSearch = function (keepForm) {

                $scope.alertType = '';
                $scope.loadingTimeout = $timeout(function () {
                    $scope.results = null;
                    $scope.isSearchLoading = true;
                }, 250);
                
                prefsSlsService.getPrefsSls().then(function (data) {
                    $scope.results = data;
                    $scope.loadView($scope.results);
                    
                    $rootScope.$broadcast('sm:resizeContainer');
                    $scope.isSearchLoading = false;
                    $timeout.cancel($scope.loadingTimeout);
                });
            };            

            $scope.loadView = function (prefsSl) {
                $state.go('edit', { id: prefsSl.priKey }, { reload: true });
                $scope.item = {
                    transferTypeOptions: [
                        {
                            name: resourceFactory.getResource('Labels', 'automaticallyUnprompted'),
                            id: 0
                        },
                        {
                            name: resourceFactory.getResource('Labels', 'manuallyPrompted'),
                            id: 1
                        }],
                    salesTypeOptions: [
                        {
                            name: resourceFactory.getResource('Labels', 'activationsAndExchanges'),
                            id: 0
                        },
                        {
                            name: resourceFactory.getResource('Labels', 'activationsOnly'),
                            id: 1
                        },
                        {
                            name: resourceFactory.getResource('Labels', 'exchangesOnly'),
                            id: 2
                        }],
                    ihcSearchOptions: [
                        {
                            name: resourceFactory.getResource('Labels', 'guestNumber'),
                            id: 0
                        },
                        {
                            name: resourceFactory.getResource('Labels', 'wtpNumber'),
                            id: 1
                        }],
                    UnassignedItems: prefsSl.unassignedItems,
                    AssignedItems:  prefsSl.assignedItems,
                    ihcXfer: prefsSl.ihCxfer,
                    ihcPType: prefsSl.ihCptype,
                    ihcStype: prefsSl.ihCstype,
                    ihcSearch: prefsSl.ihCsearch,
                    priKey: prefsSl.priKey
                }

                $scope.showForm = true;               
                $scope.isEditLoading = false;                
                $rootScope.$broadcast('sm:focus');
            };			

            $scope.$on('prefsSls:doSearch', function (event, keepForm) {
                doSearch(keepForm);
            });

            $scope.cancel = function () {
                // window.console && console.log("Cancel fired");
                $scope.form.$setPristine();
                $scope.showForm = false; // close the form
            };
            

            $scope.$on('sm:hideForm', function (event) {
                //  window.console && console.log("Cancel fired from closing the form")
                $scope.cancel();
            });

            $scope.save = function () {
                $scope.disableAction = true;
                $scope.alertType = 'saving';
                prefsSlsService.savePrefsSl($scope.item).then(function () {
                    $rootScope.$broadcast('prefsSls:doSearch', true);
                    $scope.alertType = 'success';
                    $scope.alertMessage = resourceFactory.getResource('Messages', 'successfullyUpdated')
                        .format(resourceFactory.getResource('Labels', 'ihcBalanceAssistSettings'));
                    $scope.form.$setPristine();
                    $scope.disableAction = false;
                });
            };

            init();
        }]);    
})();
Today I've tried adding reload:"true" for the LoadView function but it didn't help.

Here is the problem - I activate that page, say, from its regular menu or from the Favorites. I press 'Cancel' on that form that basically hides the view (I've tried going home also with no effect). Then after that I try to open that page from the Favorites menu again and all I see is the spinning circle. My Controller.cs code is not firing at all. The problem, I believe, is the fact that it's not reloading the page. Because if I manually click again on that URL, it does re-load and the form appears.

So, my question is - how should I make sure that I always reload?

Do you see the solution for that problem?

UPDATE. Also asked at StackOverflow http://stackoverflow.com/questions/33109910/how-to-reload-page-angularjs

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform