Selectize.js: No support for "disabled" options?

Created on 14 Dec 2013  路  14Comments  路  Source: selectize/selectize.js

When an <option> in the original <select> has a disabled attribute, the option is not disabled after being selectize'd.

It is a very big lack IMO, since disabled options are quite common. Is there plan to add support?

See this Fiddle http://jsfiddle.net/76ETp/1/

Most helpful comment

Disabled select options can also be achieved by overriding the render function.

$('#control').selectize({
  render: {
    option: function(item, escape) {
      if (item.value === '') {
        return '<div style="pointer-events: none; color: #aaa;">' + escape(item.label) + '</div>';
      }

      return '<div>' + escape(item.label) + '</div>';
    }
  }
});

All 14 comments

I need something similar. That's the option to keep option attributes. Each of my option is in a different language, so they have a lang attribute that is lost when selectized.

I just ran into this and found it's not implemented, would be a great addition!

In case someone else runs into this, here is a plugin that we wrote that handles disabling options.
https://github.com/mondorobot/selectize-disable-options

I agree this is a pretty big missing feature. Disabling options should be part of the core functionality! Any plans on this, or even feedback from the developers?

:+1:

+1

Disabled select options can also be achieved by overriding the render function.

$('#control').selectize({
  render: {
    option: function(item, escape) {
      if (item.value === '') {
        return '<div style="pointer-events: none; color: #aaa;">' + escape(item.label) + '</div>';
      }

      return '<div>' + escape(item.label) + '</div>';
    }
  }
});

Thanks @francis-li. Worked for me :+1:

@francis-li, me too :)

Thanks @francis-li.

@francis-li, it worked well! Thank you :)

How can we disable selection for keyboard events as well? "pointer-events" attribute is only for mouse events. Look forward to hearing from you soon. Thank you in advance.

I used this plugin for disabling some options https://github.com/mondorobot/selectize-disable-options

closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

John-Fratila picture John-Fratila  路  4Comments

shivika picture shivika  路  5Comments

vilimco picture vilimco  路  5Comments

aureole82 picture aureole82  路  3Comments

AndrejVM picture AndrejVM  路  3Comments