select2-bootstrap-theme icon indicating copy to clipboard operation
select2-bootstrap-theme copied to clipboard

Responsiveness

Open vanhoutenbos opened this issue 9 years ago • 9 comments

Hello,

I thought bootstrap is created to make websites responsive, but this plugin doesn't fix the responsiveness issues at all. It does style it to a nice bootstrap looking button but without the responsiveness its useless.

Could this be implemented.

vanhoutenbos avatar Nov 30 '15 16:11 vanhoutenbos

well it is strange. when we change the size of the window, it doesn't readapt but if we refresh the page it has the good size ..

psohm avatar Dec 19 '15 17:12 psohm

Exactly, its kinda strange, since there is code made for responsiveness, but it doesn't seem to work dynamicly. (I am logged in on my work account now, same guy as who asked the question though)

Jean-PaulvHouten avatar Dec 21 '15 13:12 Jean-PaulvHouten

Quick Hack that may help someone else until this is fixed:

$(function(){
setTimeout(function() {
$('span.select2-container.select2-container--bootstrap').width('100%');
}, 1000);
});
Since there doesn't seem to be an "initialized" event to hook into, I'm waiting one second after doc ready to set the spans with to 100%, which makes them responsive.

As I said, it's a total hack, but it will let you at least demo the thing!

rtsalamone avatar Jun 19 '16 11:06 rtsalamone

If I construct the select2 as per the examples, it works out of the box:

$.fn.select2.defaults.set("theme", "bootstrap");
$("#single").select2({
  width: null
});

Is this bug still valid?

ecmel avatar Jul 10 '16 16:07 ecmel

The bug still occurs, the @ecmel workaround works

Another way, to disables the width parameter by default:

$.fn.select2.defaults.set("width", null);

klarkc avatar Jul 12 '16 13:07 klarkc

I am using select2 4.0.3, and select2-bootstrap 0.1.0-beta.6

Can confirm that this bug still exists.

onebree avatar Jul 26 '16 20:07 onebree

this workaround fixes the issue:

// select2.init.js
$.fn.select2.defaults.set("theme", "bootstrap");
$.fn.select2.defaults.set("width", null);

$(document).ready(function () {
    $('select').select2();
});

using: select2 4.0.1 and select2-bootstrap 0.1.0-beta.10

nunesvictor avatar May 22 '17 19:05 nunesvictor

sir, It overlaps. p1

p2

larigyn avatar Jul 04 '17 14:07 larigyn

Here's what fixes it for me. Basically, just reset the select's parent container width after initializing it

$(function() { 
  $('#controlID').select2({ theme: 'bootstrap' }); 
  $('#controlID').parent().find('.select2-container').css('width', '');  <-- This part here
});

The theme shouldn't give a fixed with on this element though

demedos avatar Oct 12 '17 12:10 demedos