Giter Site home page Giter Site logo

Comments (8)

dreerr avatar dreerr commented on June 14, 2024

Sadly can reproduce this issue:
my html code <select ng-model="setting" ng-options="k as v | translate for (k,v) in settings" ></select>
renders as
bildschirmfoto 2014-02-05 um 17 03 23
whereas <select class="selectpicker" ng-model="setting" ng-options="k as v | translate for (k,v) in settings" ></select>
just renders
bildschirmfoto 2014-02-05 um 17 02 59
(with nothing selectable)

from angular-bootstrap-select.

thomaswdean avatar thomaswdean commented on June 14, 2024

Has this issue been addressed? Anyone have a work around?

from angular-bootstrap-select.

cwagner22 avatar cwagner22 commented on June 14, 2024

Same issue...

Edit: Ended up using this directive and it works great:

.angular.module("myApp", []).directive('selectPicker', function($timeout) {
  return {
    link: function(scope, element, attrs) {
      $timeout(function() {
        $(element).selectpicker();
      }, 0);
    }
  };
});

from angular-bootstrap-select.

thejohnfreeman avatar thejohnfreeman commented on June 14, 2024

It's better to just always run the selectpicker('refresh') method, which reacts when options change.

from angular-bootstrap-select.

tarlepp avatar tarlepp commented on June 14, 2024

See my issue about this #7

from angular-bootstrap-select.

thejohnfreeman avatar thejohnfreeman commented on June 14, 2024

So the problem is that the directive in this library doesn't observe the options for changes. It never calls selectpicker('refresh'). Here's the directive I'm using instead of this library. As a bonus, it works when I define my options using ng-repeat on an <optgroup> inside the <select>. The drawback is that it only works in browsers that support MutationObserver.

app.directive('ngSelectPicker', ['$timeout', '$parse', function($timeout, $parse) {
  return {
    link: function($scope, elt, attrs) {
      var refresh = function() {
        $(elt).selectpicker('refresh')
      }
      $timeout(refresh, 0) 
      obs = new MutationObserver(refresh)
      obs.observe(elt.get(0), {
        attributes: true,
        characterData: true,
        childList: true,
        subtree: true
      })
    }   
  }     
}])

from angular-bootstrap-select.

tarlepp avatar tarlepp commented on June 14, 2024

Yep, my solutions supports also ng-repeat, ng-options, etc. and it should also observe possible changes of that collection.

from angular-bootstrap-select.

joaoneto avatar joaoneto commented on June 14, 2024

Solved
#7

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.