Commit c9228e49 authored by Sergey Markelov's avatar Sergey Markelov

+) Allow to set select2.minimumInputLength from AjaxSelect2Widget.

   Default to 1
parent eddc1e17
......@@ -27,6 +27,7 @@ class AjaxSelect2Widget(object):
def __call__(self, field, **kwargs):
kwargs['data-role'] = u'select2-ajax'
kwargs['data-url'] = url_for('.ajax_lookup', name=field.loader.name)
kwargs['data-minimum-input-length'] = int( getattr(field, 'minimum_input_length', 1) )
allow_blank = getattr(field, 'allow_blank', False)
if allow_blank and not self.multiple:
......
......@@ -11,7 +11,7 @@
var opts = {
width: 'resolve',
minimumInputLength: 1,
minimumInputLength: $el.attr('data-minimum-input-length'),
placeholder: 'data-placeholder',
ajax: {
url: $el.attr('data-url'),
......@@ -93,6 +93,8 @@
if ($el.attr('data-allow-blank'))
opts['allowClear'] = true;
opts['minimumInputLength'] = $el.attr('data-minimum-input-length');
if ($el.attr('data-tags')) {
$.extend(opts, {
tokenSeparators: [','],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment