Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting window.location.href takes a long time
Message
From
20/10/2015 08:45:05
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01626184
Message ID:
01626214
Views:
38
>>>Hi everybody,
>>>
>>>I have a single page form. In the Cancel method of this form I tried the following code (I've added last line of code just now):
>>>
>>>
>>>$scope.cancel = function () {
>>>                $scope.form.$setPristine();
>>>                $scope.showForm = false;
>>>                window.location.href = "/";
>>>            };
>>>
>>>It works but with a considerable delay. E.g. the form disappears, but the URL changes only after about 20+ seconds to the localhost. Is there a better way to apply similar functionality? E.g. I simply want to re-set the current view to point to nothing as we "closed" that form by pressing 'Cancel'.
>>>
>>>The top of my controller has the following:
>>>
>>>
>>>(function () {
>>>    'use strict';
>>>
>>>    var app = angular.module('sysMgrApp');
>>>
>>>    app.config(['$stateProvider', function ($stateProvider) {
>>>        $stateProvider.state('home', {
>>>            url: '/',
>>>            controller: 'prefsAcsCrudController',
>>>            template: ''
>>>        }).state('accountUDFs', {
>>>            url: '/AccountUDFs',
>>>            templateUrl: 'customerAccounts/PrefsAcs/AccountsUDFs'
>>>        }).state('invoiceUDFs', {
>>>            url: '/InvoiceUDFs',
>>>            templateUrl: 'customerAccounts/PrefsAcs/InvoiceUDFs'
>>>        }).state('confirmationText', {
>>>            url: '/ConfirmationText',
>>>            templateUrl: 'customerAccounts/PrefsAcs/ConfirmationText'
>>>        });
>>>    }]);
>>>
>>>The problem I am trying to solve I described in another thread and this StackOverflow thread:
>>>
>>>http://stackoverflow.com/questions/33109910/how-to-reload-page-angularjs
>>>
>>>E.g. I go to one page form from the Favorites menu, I then press 'Cancel', then I try to open that same form again (it's supposed to go to that same URL) and then nothing happens besides spinning wheel image. My idea is to go to some place else (best to the /) so the Favorites menu will work (and it does work with that).
>>>
>>>Thanks in advance.
>>
>>Just wondering why you are using 'window.location.href' instead of sticking with ui-router ?
>
>How would I define the state to go to that same location and do nothing? Do I need to define another 'home' like state but without a controller?

I don't know - you haven't really explained how (or if) views are nested in your application. If the view into which the 'customerAccounts/PrefsAcs/InvoiceUDFs' template etc is loaded is a child view of that holding the menu items then maybe you could add a 'blank' url/template to your states and navigate to that on 'Cancel' ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform