Coder Social home page Coder Social logo

Comments (8)

hmonadjem avatar hmonadjem commented on August 18, 2024

having the same effect ... in my case its even not in an table :/

from angular-bootstrap-select.

felipegr avatar felipegr commented on August 18, 2024

@hmonadjem If it helps you, I managed to add some code to the directive that "corrects" this behavior. I don't believe it's a proper correction, but anyway, it works. I saw there was a difference between the two dropdowns created, the one which worked had the classes ".btn-group.bootstrap-select.ng-pristine.ng-untouched.ng-valid" in it and the duplicate hadn't, so what I did was to remove the wrong one.

Here's the code, I hope it is useful for you:

// Added $timeout
angular.module('angular-bootstrap-select', [])
  .directive('selectpicker', ['$parse', '$timeout', function ($parse, $timeout) {
    return {
      restrict: 'A',
      require: '?ngModel',
      priority: 10,
      compile: function (tElement, tAttrs, transclude) {
        tElement.selectpicker($parse(tAttrs.selectpicker)());
        tElement.selectpicker('refresh');
        return function (scope, element, attrs, ngModel) {
          if (!ngModel) return;

          scope.$watch(attrs.ngModel, function (newVal, oldVal) {
            scope.$evalAsync(function () {
              if (!attrs.ngOptions || /track by/.test(attrs.ngOptions)) element.val(newVal);
                element.selectpicker('refresh');
            });
          });

          ngModel.$render = function () {
            scope.$evalAsync(function () {
              element.selectpicker('refresh');
            });
          }

          // New code, removes the divs that don't have all the necessary classes
          $timeout(function () {
            if ($( 'div' ).find('.btn-group.bootstrap-select.ng-pristine.ng-untouched.ng-valid').length > 0 ) {
              $('.bootstrap-select:not(.ng-pristine.ng-untouched.ng-valid)').remove();
            }
          });
        };
      }

    };
  }]);

from angular-bootstrap-select.

hmonadjem avatar hmonadjem commented on August 18, 2024

Hi, thank you, i figured out that it happens when the selectpicker is in an
ng-if ...

Am Montag, 21. September 2015 schrieb felipegr :

@hmonadjem https://github.com/hmonadjem If it helps you, I managed to
add some code to the directive that "corrects" this behavior. I don't
believe it's a proper correction, but anyway, it works. I saw there was a
difference between the two dropdowns created, the one which worked had the
classes ".btn-group.bootstrap-select.ng-pristine.ng-untouched.ng-valid" in
it and the duplicate hadn't, so what I did was to remove the wrong one.

Here's the code, I hope it is useful for you:

// Added $timeout
angular.module('angular-bootstrap-select', [])
.directive('selectpicker', ['$parse', '$timeout', function ($parse, $timeout) {
return {
restrict: 'A',
require: '?ngModel',
priority: 10,
compile: function (tElement, tAttrs, transclude) {
tElement.selectpicker($parse(tAttrs.selectpicker)());
tElement.selectpicker('refresh');
return function (scope, element, attrs, ngModel) {
if (!ngModel) return;

      scope.$watch(attrs.ngModel, function (newVal, oldVal) {
        scope.$evalAsync(function () {
          if (!attrs.ngOptions || /track by/.test(attrs.ngOptions)) element.val(newVal);
            element.selectpicker('refresh');
        });
      });

      ngModel.$render = function () {
        scope.$evalAsync(function () {
          element.selectpicker('refresh');
        });
      }

      // New code, removes the divs that don't have all the necessary classes
      $timeout(function () {
        if ($( 'div' ).find('.btn-group.bootstrap-select.ng-pristine.ng-untouched.ng-valid').length > 0 ) {
          $('.bootstrap-select:not(.ng-pristine.ng-untouched.ng-valid)').remove();
        }
      });
    };
  }

};

}]);


Reply to this email directly or view it on GitHub
#49 (comment)
.

von mobil gesendet

from angular-bootstrap-select.

fthiemonge avatar fthiemonge commented on August 18, 2024

We are having the same issue, but only with the minified js.

from angular-bootstrap-select.

zdolin avatar zdolin commented on August 18, 2024

+1

from angular-bootstrap-select.

StefanOrzu avatar StefanOrzu commented on August 18, 2024

@hmonadjem is right. It happened to me when the select was nested inside an ng-if or ng-switch-when. I worked around it by placing the conditional directly on the select.
It's not a nice solution, but at least it got the job done. A real fix is still necessary for this bug.

from angular-bootstrap-select.

KevinHoward avatar KevinHoward commented on August 18, 2024

#57 <-- Here is the real fix. Thanks @xixao!

from angular-bootstrap-select.

 avatar commented on August 18, 2024

hey any one know how to give select filter in ng-table column i saw the doc but i cant understand any one have complete code

from angular-bootstrap-select.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.