GithubHelp home page GithubHelp logo

Comments (12)

caseyjhol avatar caseyjhol commented on May 1, 2024 1

That works if the menu is already displayed, but liHeight is calculated when the select is first created (while the menu is hidden), meaning outerHeight(true) doesn't work (returns a value of 6, when the value should be 26). This shouldn't really be an issue, as the line-height is set to 20px in the Bootstrap CSS, so it should never return NaN. Regardless, that whole feature probably needs a revamp, as I haven't really looked at it since I first introduced it at the beginning of December. I'll take a second look to figure out a better implementation.

from bootstrap-select.

silviomoreto avatar silviomoreto commented on May 1, 2024

Have you tried to apply seletpicker after changing your DOM?

try execute $('.selectpicker').selectpicker(); again

from bootstrap-select.

dfliess avatar dfliess commented on May 1, 2024

I wish I can do that but I'm using this at a Backbone.View on the render method and kind of calling .selectpicker inside the method, and the element is added to the DOM later, not by the View itself.

from bootstrap-select.

kayzee avatar kayzee commented on May 1, 2024

Confirmed that executing this again does not fix the size issue.
$('.selectpicker').selectpicker();

from bootstrap-select.

kayzee avatar kayzee commented on May 1, 2024

Also confirmed that commit 1c22c037178756ac894035bbbf2973887560e71a does not fix the size refresh problem.

from bootstrap-select.

kayzee avatar kayzee commented on May 1, 2024

Don't mean to be a pest, but any plans on fixing this bug?

from bootstrap-select.

mattbryson avatar mattbryson commented on May 1, 2024

Just looking at this for first time...

menuA.css('line-height') will return the CSS value of the element.

This is both browser and setting dependent, so it could be 25, '25px', or '' or 'normal'.

An empty string, or 'normal' will NOT parse to int with parseInt, you will get NaN.

So if you dont set the line-height to a int value, and you set data-size or data you will see this issue.

Can we not just use .height(); ?

from bootstrap-select.

mattbryson avatar mattbryson commented on May 1, 2024

In fact, why does it need the combination of line-height and outerHeight() ?

Can it not just use outerHeight(true) - true to include margins.

knocked a fiddle showing the issues: http://jsfiddle.net/Msyym/

m.

from bootstrap-select.

caseyjhol avatar caseyjhol commented on May 1, 2024

While I think size probably needs to be readdressed at some point, this seems to get the job done for now.

from bootstrap-select.

kayzee avatar kayzee commented on May 1, 2024

Hey @caseyjhol, the most recent changes still don't solve my problem. Maybe it is different than what @dfliess described above. I set size to 10 and with 10 options present, I add an 11th element with the following:

$("#select_list option[value='']").after("<option value='#{value}' class='local'>#{value}</option>")
$("#select_list").selectpicker('reloadLi')  # reload the list (IE8 support)

I know that the size only gets calculated in the init method. Can you think of a clean way to "refresh" the control after adding/removing a new element? (Maybe moving the size calculation code into its own method that can be called from the refresh or reloadLi methods?)

from bootstrap-select.

mattbryson avatar mattbryson commented on May 1, 2024

HI @kayzee,

Yeah, we could extract the size logic into its own function, and then call that on both init and a new method that forces a complete re build, such as refresh, as suggested in #52

m

from bootstrap-select.

MikeMazz23 avatar MikeMazz23 commented on May 1, 2024

So there are 2 common practices to make bootstrap type dropdowns. First is to use a select and the second is to a ul and li options (data toggle and dropdown-menu). When you use the select version, the first time the dropdown is expanded a ul is created with all li options having the values from the select options tags. There are now 2 lists in your page DOM. The ul li list and the original select. When you continue to play with the dropdown you will see the li class gets "selected" added to the option you picked, however the original select remains unchanged. The chrome dev tools shows this nicely by highlighting what has changed. This is probably why the size doesn't take effect immediately, bc it has to create the ul li list first. Why not does init? who knows..
This is unfortunate bc now we cannot use this great plugin with selects, only ul lists.
I know this issue was closed a long time ago, but maybe this will shed some light on the issue and help someone find a solution.

from 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.