mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Ajoute des suggestions quand rien n'est écrit
This commit is contained in:
parent
a156010262
commit
e5bdff792b
1 changed files with 14 additions and 3 deletions
|
@ -142,7 +142,7 @@ def typeahead_choices( f_value ) :
|
||||||
'];'
|
'];'
|
||||||
|
|
||||||
def typeahead_engine () :
|
def typeahead_engine () :
|
||||||
return 'var choices = new Bloodhound({ ' \
|
return 'var engine = new Bloodhound({ ' \
|
||||||
'datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"), ' \
|
'datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"), ' \
|
||||||
'queryTokenizer: Bloodhound.tokenizers.whitespace, ' \
|
'queryTokenizer: Bloodhound.tokenizers.whitespace, ' \
|
||||||
'local: choices, ' \
|
'local: choices, ' \
|
||||||
|
@ -153,7 +153,7 @@ def typeahead_datasets( f_name ) :
|
||||||
return '{ ' \
|
return '{ ' \
|
||||||
'hint: true, ' \
|
'hint: true, ' \
|
||||||
'highlight: true, ' \
|
'highlight: true, ' \
|
||||||
'minLength: 1 ' \
|
'minLength: 0 ' \
|
||||||
'}, ' \
|
'}, ' \
|
||||||
'{ ' \
|
'{ ' \
|
||||||
'templates: { ' \
|
'templates: { ' \
|
||||||
|
@ -161,7 +161,18 @@ def typeahead_datasets( f_name ) :
|
||||||
'}, ' \
|
'}, ' \
|
||||||
'display: "value", ' \
|
'display: "value", ' \
|
||||||
'name: "'+f_name+'", ' \
|
'name: "'+f_name+'", ' \
|
||||||
'source: choices ' \
|
'source: function(q, sync) {' \
|
||||||
|
'if (q === "") {' \
|
||||||
|
'var nb = 10;' \
|
||||||
|
'var first = [] ;' \
|
||||||
|
'for ( var i = 0 ; i < nb ; i++ ) {' \
|
||||||
|
'first.push(choices[i].value);' \
|
||||||
|
'}' \
|
||||||
|
'sync(engine.get(first));' \
|
||||||
|
'} else {' \
|
||||||
|
'engine.search(q, sync)' \
|
||||||
|
'}' \
|
||||||
|
'}' \
|
||||||
'}'
|
'}'
|
||||||
|
|
||||||
def typeahead_updater( f_name ):
|
def typeahead_updater( f_name ):
|
||||||
|
|
Loading…
Reference in a new issue