Skip to content

Commit

Permalink
Timeout added to make the chosen widget wrapper to work with Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
kyolee310 committed Feb 7, 2014
1 parent 63b46bc commit 3333b13
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions koala/static/js/pages/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@ angular.module('GroupPage', [])
};
$scope.activateChosen = function () {
$("#users-select").chosen();
$("#users_select_chosen .chosen-choices").bind("DOMSubtreeModified", function() {
var newUsers = [];
$("#users_select_chosen .chosen-choices .search-choice").each(function (index){
var thisUser = $( this ).text();
newUsers.push(thisUser);
});
var userRemoved = false;
if( $scope.groupUsers.length < newUsers.length ){
userRemoved = true;
}
$scope.groupUsers = newUsers;
if( userRemoved ){
$scope.$apply();
}
$("#users_select_chosen .chosen-choices").bind("DOMSubtreeModified", function(e) {
$timeout(function(){ $scope.adjustGroupUsers(); }, 100);
});
};
$scope.adjustGroupUsers = function () {
var newUsers = [];
$("#users_select_chosen .chosen-choices .search-choice").each(function (index){
var thisUser = $( this ).text();
newUsers.push(thisUser);
});
var userAdded = false;
if( $scope.groupUsers.length < newUsers.length ){
userAdded = true;
}
$scope.groupUsers = newUsers;
if( userAdded == true ){
$scope.$apply();
}
};
$scope.removeUser = function (user) {
$("#users_select_chosen .chosen-choices .search-choice").each(function (index){
Expand Down

0 comments on commit 3333b13

Please sign in to comment.