Comments (8)
having the same effect ... in my case its even not in an table :/
from angular-bootstrap-select.
@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.
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.
We are having the same issue, but only with the minified js.
from angular-bootstrap-select.
+1
from angular-bootstrap-select.
@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.
#57 <-- Here is the real fix. Thanks @xixao!
from angular-bootstrap-select.
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)
- Question : Why does not default selectpicker work?
- 0.1.0-rc2 files under build folder is not built from src?
- Still have 'Nothing Selected' when trying to use Ng-options HOT 1
- Up/Down keys do not work with options list
- ng-options Doesn't Rebind After Scope Variable Change HOT 12
- bower package is not published
- Default picker choice? HOT 1
- selectpicker directive not in README file
- Significant slow down with a lot of options HOT 1
- Multi render
- syntax err line 8 HOT 1
- Doesn't support track by in ng-option HOT 1
- dropdown-toggle doesn't close when used within ng-form
- Support for optgroups?
- Is there a support for options with search? HOT 1
- with ng-model twice selct boxes HOT 1
- ng-options support in angular 1.4
- Livesearch to filter data by mapping string in the begining
- Click event not triggered on document
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-bootstrap-select.