Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
0cb784fc
Commit
0cb784fc
authored
Oct 06, 2017
by
Maël Kervella
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Empty label dans le placeholder + bind (''->empty value)
parent
e5bdff79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
machines/templatetags/bootstrap_form_typeahead.py
machines/templatetags/bootstrap_form_typeahead.py
+13
-3
No files found.
machines/templatetags/bootstrap_form_typeahead.py
View file @
0cb784fc
...
...
@@ -73,6 +73,7 @@ def bootstrap_form_typeahead(django_form, typeahead_fields, *args, **kwargs):
f_value
.
widget
=
TextInput
(
attrs
=
{
'name'
:
'typeahead_'
+
f_name
,
'placeholder'
:
f_value
.
empty_label
}
)
form
+=
render_field
(
...
...
@@ -124,13 +125,16 @@ def typeahead_full_script( f_name, f_value ) :
').bind(
\n
'
+
\
'"typeahead:select", '
+
\
typeahead_updater
(
f_name
)
+
'
\n
'
+
\
').bind(
\n
'
+
\
'"typeahead:change", '
+
\
typeahead_change
(
f_name
)
+
'
\n
'
+
\
')
\n
'
+
\
'});
\n
'
return
render_tag
(
'script'
,
content
=
mark_safe
(
js_content
)
)
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
)
:
return
'var choices = ['
+
\
...
...
@@ -179,5 +183,11 @@ def typeahead_updater( f_name ):
return
'function(evt, item) { '
\
'$("#'
+
hidden_id
(
f_name
)
+
'").val( item.key ); '
\
'return item; '
\
'}'
'}'
def
typeahead_change
(
f_name
):
return
'function(evt) { '
\
'if (evt.currentTarget.value === "") {'
\
'$("#'
+
hidden_id
(
f_name
)
+
'").val(""); '
\
'}'
\
'}'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment