bootstrap-switch icon indicating copy to clipboard operation
bootstrap-switch copied to clipboard

the option size is doesn't work?

Open jerry-yuan opened this issue 7 years ago • 7 comments

No matter whether I use the $(...). bootstrapSwitch ({size:"small"}) or add data-size = "small" to the input, I can't achieve small space. By the way, I found that there are lots of bootstrap-switch-undefined in the class attribute of wrapper which contains the switch elements.

jerry-yuan avatar Sep 26 '18 10:09 jerry-yuan

I have the same problem. i use the CSS file and not the less file.

WebCustoms avatar Oct 08 '18 01:10 WebCustoms

CSS and JS are v.3.3.4 on the demo site as in the repository, but the version on the site works! bootstrap-switch.js bootstrap-switch.css

matusmark avatar Oct 25 '18 23:10 matusmark

https://github.com/Bttstrp/bootstrap-switch/blob/master/dist/js/bootstrap-switch.js

function getClasses(options, id) {
    var state = options.state,
        size = options.size,
        disabled = options.disabled,
        readonly = options.readonly,
        indeterminate = options.indeterminate,
        inverse = options.inverse;

    return [state ? 'on' : 'off', size, disabled ? 'disabled' : undefined, readonly ? 'readonly' : undefined, indeterminate ? 'indeterminate' : undefined, inverse ? 'inverse' : undefined, id ? 'id-' + id : undefined].filter(function (v) {
      return v == null;
    });
  }

be revised as

function getClasses(options, id) {
    var state = options.state,
        size = options.size,
        disabled = options.disabled,
        readonly = options.readonly,
        indeterminate = options.indeterminate,
        inverse = options.inverse;

    return [state ? 'on' : 'off', size, disabled ? 'disabled' : undefined, readonly ? 'readonly' : undefined, indeterminate ? 'indeterminate' : undefined, inverse ? 'inverse' : undefined, id ? 'id-' + id : undefined].filter(function (v) {
      return v != null;
    });
  }

Returns the option of null: return v == null;

So it's all undefined

woodynew avatar Nov 09 '18 07:11 woodynew

@matusmark bootstrap-switch. Js is right

woodynew avatar Nov 09 '18 07:11 woodynew

@Wong-Dy you are correct, please submit a pull-request because it works as intended just by changing that

insmod avatar Feb 07 '19 18:02 insmod

FYI Fixed by #713 Still waiting for this PR to be merged.

jybleau avatar Sep 19 '19 00:09 jybleau

https://github.com/Bttstrp/bootstrap-switch/blob/master/dist/js/bootstrap-switch.js

function getClasses(options, id) {
    var state = options.state,
        size = options.size,
        disabled = options.disabled,
        readonly = options.readonly,
        indeterminate = options.indeterminate,
        inverse = options.inverse;

    return [state ? 'on' : 'off', size, disabled ? 'disabled' : undefined, readonly ? 'readonly' : undefined, indeterminate ? 'indeterminate' : undefined, inverse ? 'inverse' : undefined, id ? 'id-' + id : undefined].filter(function (v) {
      return v == null;
    });
  }

be revised as

function getClasses(options, id) {
    var state = options.state,
        size = options.size,
        disabled = options.disabled,
        readonly = options.readonly,
        indeterminate = options.indeterminate,
        inverse = options.inverse;

    return [state ? 'on' : 'off', size, disabled ? 'disabled' : undefined, readonly ? 'readonly' : undefined, indeterminate ? 'indeterminate' : undefined, inverse ? 'inverse' : undefined, id ? 'id-' + id : undefined].filter(function (v) {
      return v != null;
    });
  }

Returns the option of null: return v == null;

So it's all undefined

I had a try as this just, but it seems not to work

zhaowenquan131 avatar Mar 19 '20 02:03 zhaowenquan131