How to change the "Add" word on jQuery Selectize plugin?
Asked Answered
D

1

20

I may have missed it in docs but I cannot find how to change the "Add" word in options. Is it possible?

@Shiva - I looked through the code on github but haven't found the answer to my question. My code is following:

<div class="sandbox" style="width: 200px">
  <input id="input-tags" class="demo-default selectized" type="text" tabindex="-1" style="display: none;">
  <div class="selectize-control demo-default multi">
    <div class="selectize-input items not-full has-options has-items" style="display:none">
      <div class="selectize-dropdown demo-default multi" style="display: none;">
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
  $(function() {
    $('#input-tags').selectize({
      valueField: 'id',
      labelField: 'name',
      searchField: 'name',
      plugins: ['remove_button'],
      createOnBlur: true,
      delimiter: ',',
      persist: false,
      hideSelected: true,
      onChange: function(input) {
        console.log(input);
      },
      create: true,
      load: function(query, callback) {
        if (!query.length)
          return callback();
        $.ajax({
          url: $('#selectizeUrl').val()+"/term/"+query,
          type: 'GET',
          dataType: 'json',
          error: function() {
            callback();
          },
          success: function(res) {
            console.log(res);
            callback(res);
          }
        });
      }

    });
  });
</script>
Douma answered 7/2, 2014 at 22:44 Comment(3)
Please share code you've tried, and/or links to the plugin.Orion
There is no code. OP wants to know how to change the "Add..." text that appears when you implement this plugin for adding to existing lists, tags etc. See the demo page on github..Godhood
answer is here: github.com/brianreavis/selectize.js/blob/master/docs/…Shirelyshirey
D
51

I have found an answer to the question. I defined render option for selectize like that:

render: {
    option_create: function(data, escape) {
      return '<div class="create">Dodaj <strong>' + escape(data.input) + '</strong>&hellip;</div>';
    }
  },
Douma answered 15/2, 2014 at 18:0 Comment(3)
vide github.com/brianreavis/selectize.js/blob/master/docs/…Shirelyshirey
I learned the hard way that the create class in the returned div is crucial.Mariellamarielle
@vide Link is invalid. Issue also solved here github.com/selectize/selectize.js/issues/16Phylactery

© 2022 - 2024 — McMap. All rights reserved.