Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selectize.js - how can I disable the flashing cursor after the selected item?

I'm using selectize.js to style text boxes, and it's working fine.

$("select[name='somename']").selectize({
  valueField: 'id',
  labelField: 'name',
  searchField: 'name',
  options: selectableThings,
  render: {
    option: function(item, escape) {
      return render(someTemplate, item);
    },
    item: function(item, escape) {
      return render(someTemplate, item);
    }
  }
});

However I have a limited range of items and do not wish for the cursor (flashing |) to be enabled all the time. I've searched through the API docs and the source but can't find anything obvious.

Is there something inbuilt to disable the flashing cursor?

Edit originally has this as 'disabling input' but it looks like the cursor can't be used for input (and disabling input still shows the cursor).

like image 421
mikemaccana Avatar asked Sep 25 '13 15:09

mikemaccana


1 Answers

Selectize isn't particularly designed to act just as a select decorator. The cursor comes from an <input> element that allows the user wittle down options. Hiding the input will create strange behavior when the user types. Also, when the control is empty, the input is used to display the placeholder text.

Technically you can hide the cursor (and input) with CSS:

/* option a: make transparent */
.selectize-input input {
    color: transparent !important;
}

/* option b: position off-screen */
.selectize-input input {
    position: absolute !important;
    top: -9999px;
    left: -9999px;
}

But again, this is going to feel funky. I'll look into writing a decorator_only plugin that disables keyboard handling, but it's not an immediate priority.

http://jsfiddle.net/mARDE/1/

like image 185
brianreavis Avatar answered Oct 21 '22 22:10

brianreavis