Skip to content
Snippets Groups Projects
Commit 6d906897 authored by gloas's avatar gloas
Browse files

dev #14372 addinf minLength 3 to search_autocomplete

parent f141edf8
Branches
Tags
5 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!215Dev#12992 Custom Fields,!209Hotline#13914 Album Link Config Menu,!190Dev#12691 Autocomplete,!185Dev#12691 Autocomplete
......@@ -33,6 +33,7 @@ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil
'action' => 'suggestajax'], null, true);
$options->dataType = 'json';
$options->dataLabel = 'startsWith';
$options->minLength = 3;
return json_encode($options);
}
......
......@@ -24,14 +24,14 @@
source: function(query, response) {
var datas = {};
datas[options.dataLabel] = node.val();
$.ajax({
url: options.url,
dataType: 'json',
data: datas,
success: function(data) {response(data);}
});
}
},
minLength: options.minLength
});
};
} (jQuery));
......
......@@ -26,10 +26,10 @@ QUnit.module('search_autocomplete', {
}
fixture = $('<input class="expressionRecherche" name="q" type="text" value="" />');
fixture.search_autocomplete({url : 'my_bokeh/recherche/suggestajax',
dataType : 'json',
dataLabel : 'startsWith'});
dataLabel : 'startsWith',
minLength: 3});
fixture.val('topo');
fixture.autocomplete('search');
}
......@@ -50,3 +50,11 @@ test('autocomplete should call ajax with correct data type', function() {
equal(options.dataType, 'json');
});
test('autocomplete should no call ajax with expected minLength', function() {
options = null;
fixture.val('op');
fixture.autocomplete('search');
equal(options, null);
});
......@@ -44,7 +44,7 @@ class ZendAfi_View_Helper_Accueil_RechSimpleTest extends ViewHelperTestCase {
/** @test */
public function searchAutocompleteShouldBeCallWithExpectedParams() {
$expected_ajax_param = '/recherche\/suggestajax","dataType":"json","dataLabel":"startsWith"}';
$expected_ajax_param = '/recherche\/suggestajax","dataType":"json","dataLabel":"startsWith","minLength":3}';
$this->assertXPathContentContains($this->_head_script, '//script', $expected_ajax_param);
}
......
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