Performance Bug : Digest on one instance triggers on digest on others
If have multiple multi selects in one page, on opening on multiselect, digest is run on every other instance. When I have 30+ multiselects, it takes 3 seconds to open a multiselect.
Hi @jsrockstar132 ,
Noted, thanks for this. Will take note for future version.
Hey isteven,
we´re facing the exact same problem here. We´re using a function to generate our inputmodels and have about 10 places where we use your directive. Everytime we open/hover/click any element in any directive, every instance of the directive updates their complete input model.
In real browsers the performance issue is notable but tolerable. In all versions of IE, the javacript engine however has serious issues computing all the method calls and freezes for up to 10 seconds.
Hi @jannisbreitwieser ,
May I know if you re-use the same input-model $scope variable for every instance of the directive?
Hi steven,
we´ve got one "view/template" that uses a single controller. This controller has a single $scope variable. On this $scope a function is defined like: $scope.calculateInputModel();
In the template the
Hovering over an option for example causes the calculateInputModel() method to be called n (number of directive - 10 in this case) times.
Tested both with multi-select 2.x and the current 4.x version of the directive. Also had a look at your code. At first glance I dont understand, why the input-model is a two way binding here?
Hope that helps.
Jannis
Hi,
Perhaps to make it clear; did you use the same input model for each directive? Say:
Controller
$scope.myArrOfObjects = [ ..... ]
View
Select 1
<div isteven-multi-select input-model="myArrOfObjects" .... ></div>
Select 2
<div isteven-multi-select input-model="myArrOfObjects" .... ></div>
Select 3
<div isteven-multi-select input-model="myArrOfObjects" .... ></div>
May I know if it's like that? Or perhaps you can replicate your code in Plunker or JsFIddler.
The second watcher for scope.inputModel is causing problems in IE, Pages get stuck if you have multiple multi-select directives Disabled it temporarily at the cost of the reset button functionality.
// watch1, for changes in input model property
// updates multi-select when user select/deselect a single checkbox programatically
// https://github.com/isteven/angular-multi-select/issues/8
$scope.$watch( 'inputModel' , function( newVal ) {
if ( newVal ) {
$scope.refreshOutputModel();
$scope.refreshButton();
}
}, true );
//watch2 for changes in input model as a whole
//this on updates the multi-select when a user load a whole new input-model. We also update the $scope.backUp variable
$scope.$watch( 'inputModel' , function( newVal ) {
if ( newVal ) {
$scope.backUp = angular.copy( $scope.inputModel );
$scope.updateFilter();
$scope.prepareGrouping();
$scope.prepareIndex();
$scope.refreshOutputModel();
$scope.refreshButton();
}
});
Use angular.copy(data) to make data different!!! If data in select boxes the same... to prevent it
jqgrid multiselect disabling the whole thing takes a lot of time any suggestions on how to improve the disabling time.