javascript - document.location.href not working consistently -
i have angular based site i'm building , i've hit odd error i'm totally stumped on. it's law firm. 1 of pull down menus list of lawyers. when click on one, page loads fine. if go click on different lawyer, url changes proper url 2 strange things happen.
1) doesn't go there. 2) entire pulldown shades if it's mid-click , seems stuck there.
rather butcher code here, figured i'd link site can see in action. will, however, copy here associated controller since i'm not sure you'll able see enough otherwise.
again, works except when try click on attorney's name when i'm on bio page of attorney.
attorneycontroller.js
app.controller('attorneycontroller', ['$scope', '$location', 'attorneys', '$sce', function($scope, $location, attorneys, $sce) { var quotelist = []; $scope.myfunctions = {}; var practiceareas = { altdispute: "alternative dispute resolution", businesscorp: "businesses & corporations", estateplanning: "estate planning", futures: "futures & derivatives", litigation: "litigation", productliability: "product liability", realestate: "real estate", securities: "securities" }; // load bio content $scope.myfunctions.load_bio = function(bionum){ var urlstr = $basehref + "bio.php#/?bio_id=" + bionum; document.location.href = urlstr; } attorneys.success(function(data){ var quotelist = []; function quoteflip(quotelist, id, total){ window.cleartimeout(timeoutquotes); var src1 = quotelist[id]; $("#bio_quotes").fadeout(500, function(){ $("#bio_quotes").html(src1).fadein(500); }); var idno = (id + 1) % total; var timeoutquotes = window.settimeout(function(){quoteflip(quotelist, idno, quotelist.length);}, 5000); } if($location.search().bio_id > 0){ $scope.myfunctions.bio_id = $location.search().bio_id; var matches = $.grep(data.attorneys, function(obj) { return obj.id == $location.search().bio_id; }); if (matches.length === 1) { $scope.thisattorney = matches[0]; quotelist = $scope.thisattorney.quotes; $("#bio_quotes").html(quotelist[0]); } }else{ $scope.myfunctions.bio_id = 0; }; $scope.attorneys = data.attorneys; $scope.practiceareas = practiceareas; var timeoutquotes = window.settimeout(function(){quoteflip(quotelist, 1, quotelist.length);}, 5000); }); }]); the url see in action
http://www.gelerinter.com/dev_sites/lksu
click on attorneys in top nav , select first one. then, once on page, click attorneys again , select mitchell goldberg. you'll see url change, lock up.
don't try set document.location.href manually, instead use route provider or location service.
Comments
Post a Comment