How to use the select2/defaults.set function in select2

To help you get started, we’ve selected a few select2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github select2 / select2 / tests / options / ajax-tests.js View on Github external
test('more than one default option can be changed via set()', function(assert) {
  var defaults = require('select2/defaults');
  var ajaxDelay = 123;
  var dataDataType = 'xml';
  defaults.set('ajax--delay', ajaxDelay);
  defaults.set('ajax--data-type', dataDataType);

  assert.equal(
      defaults.defaults.ajax.delay,
      ajaxDelay,
      'Both ajax.delay and ajax.dataType present in defaults');
  assert.equal(
    defaults.defaults.ajax.dataType,
    dataDataType,
    'Both ajax.delay and ajax.dataType present in defaults');
  defaults.reset();
});
github select2 / select2 / tests / options / ajax-tests.js View on Github external
test('options are merged recursively with default options', function (assert) {
  var defaults = require('select2/defaults');

  var ajaxDelay = 250;
  var ajaxUrl = 'http://www.test.com';

  var mergedOptions;

  defaults.set('ajax--delay', ajaxDelay);

  mergedOptions = defaults.apply({
    ajax: {
      url: ajaxUrl
    }
  });

  assert.equal(
    mergedOptions.ajax.delay,
    ajaxDelay,
    'Ajax default options are present on the merged options'
  );

  assert.equal(
    mergedOptions.ajax.url,
    ajaxUrl,
github select2 / select2 / tests / options / ajax-tests.js View on Github external
test('more than one default option can be changed via set()', function(assert) {
  var defaults = require('select2/defaults');
  var ajaxDelay = 123;
  var dataDataType = 'xml';
  defaults.set('ajax--delay', ajaxDelay);
  defaults.set('ajax--data-type', dataDataType);

  assert.equal(
      defaults.defaults.ajax.delay,
      ajaxDelay,
      'Both ajax.delay and ajax.dataType present in defaults');
  assert.equal(
    defaults.defaults.ajax.dataType,
    dataDataType,
    'Both ajax.delay and ajax.dataType present in defaults');
  defaults.reset();
});
github select2 / select2 / tests / options / translation-tests.js View on Github external
test('lang attr overrides default language', function (assert) {
  var $element = $('<select lang="it"></select>');

  Defaults.set('language', 'es');

  var options = new Options({}, $element);

  assert.deepEqual(
    options.get('language'),
    ['it', 'es', 'en']
  );
});
github select2 / select2 / tests / options / translation-tests.js View on Github external
test('partial dictionaries can be combined with defaults', function (assert) {
  var $element = $('<select></select>');

  Defaults.set('language', {
    test: function () {
      return 'Testing';
    }
  });

  var options = new Options({
    language: {
      searching: function () {
        return 'Something';
      }
    }
  }, $element);

  var translations = options.get('translations');

  assert.equal(

select2

Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis