mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Empty label dans le placeholder + bind (''->empty value)
This commit is contained in:
parent
e5bdff792b
commit
0cb784fcf1
1 changed files with 12 additions and 2 deletions
|
@ -73,6 +73,7 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
|
||||||
f_value.widget = TextInput(
|
f_value.widget = TextInput(
|
||||||
attrs={
|
attrs={
|
||||||
'name': 'typeahead_'+f_name,
|
'name': 'typeahead_'+f_name,
|
||||||
|
'placeholder': f_value.empty_label
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
form += render_field(
|
form += render_field(
|
||||||
|
@ -124,13 +125,16 @@ def typeahead_full_script( f_name, f_value ) :
|
||||||
').bind(\n' + \
|
').bind(\n' + \
|
||||||
'"typeahead:select", ' + \
|
'"typeahead:select", ' + \
|
||||||
typeahead_updater( f_name ) + '\n' + \
|
typeahead_updater( f_name ) + '\n' + \
|
||||||
|
').bind(\n' + \
|
||||||
|
'"typeahead:change", ' + \
|
||||||
|
typeahead_change( f_name ) + '\n' + \
|
||||||
')\n' + \
|
')\n' + \
|
||||||
'});\n'
|
'});\n'
|
||||||
|
|
||||||
return render_tag( 'script', content=mark_safe( js_content ) )
|
return render_tag( 'script', content=mark_safe( js_content ) )
|
||||||
|
|
||||||
def reset_input( f_name, f_value ) :
|
def reset_input( f_name, f_value ) :
|
||||||
return '$("#'+input_id(f_name)+'").val("'+f_value.empty_label+'");'
|
return '$("#'+input_id(f_name)+'").val("");'
|
||||||
|
|
||||||
def typeahead_choices( f_value ) :
|
def typeahead_choices( f_value ) :
|
||||||
return 'var choices = [' + \
|
return 'var choices = [' + \
|
||||||
|
@ -179,5 +183,11 @@ def typeahead_updater( f_name ):
|
||||||
return 'function(evt, item) { ' \
|
return 'function(evt, item) { ' \
|
||||||
'$("#'+hidden_id(f_name)+'").val( item.key ); ' \
|
'$("#'+hidden_id(f_name)+'").val( item.key ); ' \
|
||||||
'return item; ' \
|
'return item; ' \
|
||||||
'}'
|
'}'
|
||||||
|
|
||||||
|
def typeahead_change( f_name ):
|
||||||
|
return 'function(evt) { ' \
|
||||||
|
'if (evt.currentTarget.value === "") {' \
|
||||||
|
'$("#'+hidden_id(f_name)+'").val(""); ' \
|
||||||
|
'}' \
|
||||||
|
'}'
|
||||||
|
|
Loading…
Reference in a new issue