javascript - $locationChangeSuccess not firing on browser back action in IE10 and IE11 -
on project i'm working on, number of checkboxes in view used apply , remove set of filters search result set. values of these checkboxes written query string facilitate ability pre-load filter state via navigation. simplify, i'll pretend there 1 checkbox , ignore fact there's supposed filtering.
to ensure state in query string correct, when check-box checked, function called writes checkbox's value query string. checkbox's value bound scope property called "checkboxvalue".
<input ng-model="checkboxvalue" ng-change="writevaluetoquerystring()" type="checkbox"/>
in addition this, when there update query string, call function gets current value query string , writes $scope.checkboxvalue. ensures value in controller , value in query string in sync 1 another, regardless of change in value originates. altogether simplified version of looks this:
app = angular.module 'myapp', [] app.controller 'myctrl', ['$scope', '$location', ($scope, $location) -> $scope.getvaluefromquerystring = () -> querystringvalue = $location.search()['checkbox'] or false #making sure write true/false , not "true"/"false" $scope.checkboxvalue = querystringvalue true or querystringvalue 'true' $scope.writevaluetoquerystring = () -> $location.search 'checkbox', $scope.checkboxvalue.tostring() $scope.$on '$locationchangesuccess', () -> $scope.getvaluefromquerystring() ]
when check box, changes checkboxvalue, updates value in query string, , lovely. if press "back" button in browser, notices location has changed, updates value match query string (efectively undoing last), , lovely.
...unless i'm using internet explorer 10 or 11...
in ie10 , ie11, browser "back" action doesn't appear anything. in reality, is performing browser "back" action (when @ it, query string reads should after browser "back" action). problem seems $locationchangesuccess never fires. value never retrieved query string, means checkbox's actual value never updated query string. eventually, if press "back" enough, boots off whatever actual page on before got own page, checkbox still in state before started hitting "back".
funny thing is? ie8 , ie9 have no problems this.
link codepen (try in ie10 or ie11): http://codepen.io/anon/pen/zagwt/
thanks reading ramblings long. give on issue tremendously appreciated!
things i've tried:
$scope.$watch ( () -> $location.search() ), () -> $scope.getvaluefromquerystring()
which appears behave identically what's listed above. no dice.
Comments
Post a Comment