Disable “remove on backspace” (or remove ibeam entirely)

泪湿孤枕 提交于 2019-12-05 10:17:53

A little late to the game...

I wanted to stop backspace from removing items but keep the functionality of the remove buttons.

I wrote this plugin:

Selectize.define("stop_backspace_delete", function (options) {
  var self = this;

  this.deleteSelection = (function() {
    var original = self.deleteSelection;

    return function (e) {
      if (!e || e.keyCode !== 8) {
        return original.apply(this, arguments);
      }

      return false;
    };
  })();
});

I've added 3 new config options, submitted them to github and also made a PR.

  1. disableDelete: disable "delete on backspace"
  2. disableCaret: disable moving between items
  3. hidePlaceholder: hide the place holder when there is at least one item selected

Until the PR is accepted here is my repo: https://github.com/deiucanta/selectize.js

I just created a Selectize plugin that removes the ability for the user to deselect options. It completely prevents removing items via backspace or delete buttons.

https://github.com/akrikos/selectize-no-delete

You'll need to include the js file and add the plugin to your selectize options:

$('#selectElement').selectize({
  plugins: {
    'no-delete': {}
  }
});

I don't know about earlier version.

But now you can just add in configuration.

persist: true.

For disabling deleting you will probably change the source. Here you have relevant code fragments: https://github.com/brianreavis/selectize.js/blob/master/src/selectize.js#L434 and https://github.com/brianreavis/selectize.js/blob/master/src/selectize.js#L1557

Second thing would be simillar.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!