Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
81145a0d
Commit
81145a0d
authored
Feb 19, 2020
by
Marc Egger
Browse files
add static list to normal typeahead. works
parent
b63e82a8
Pipeline
#3301
passed with stages
in 3 minutes and 39 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
javascript/src/TypeAhead.js
View file @
81145a0d
...
...
@@ -354,14 +354,14 @@ var QfqNS = QfqNS || {};
// bind change event
if
(
!!
$element
.
data
(
'
typeahead-pedantic
'
))
{
// Typeahead pedantic: Only allow suggested inputs
$element
.
bind
(
'
typeahead:change
'
,
n
.
TypeAhead
.
makePedanticHandler
(
suggestions
));
$element
.
on
(
'
keydown
'
,
(
function
(
suggestions
)
{
$element
.
bind
(
'
typeahead:change
'
,
n
.
TypeAhead
.
makePedanticHandler
());
$element
.
on
(
'
keydown
'
,
function
()
{
return
function
(
event
)
{
if
(
event
.
which
===
13
)
{
n
.
TypeAhead
.
makePedanticHandler
(
suggestions
)(
event
);
n
.
TypeAhead
.
makePedanticHandler
()(
event
);
}
};
})
(
suggestions
))
;
});
// The pedantic handler will test if the shadow element has a value set (the KEY). If not, the
// typeahead element is cleared. Thus we have to guarantee that no value exists in the shadow
// element the instant the user starts typing since we don't know the outcome of the search.
...
...
@@ -413,7 +413,7 @@ var QfqNS = QfqNS || {};
};
};
n
.
TypeAhead
.
makePedanticHandler
=
function
(
bloodhound
)
{
n
.
TypeAhead
.
makePedanticHandler
=
function
()
{
return
function
(
event
)
{
var
$typeAhead
=
$
(
event
.
delegateTarget
);
var
$shadowElement
=
n
.
TypeAhead
.
getShadowElement
(
$typeAhead
);
...
...
mockup/typeahead.php
View file @
81145a0d
...
...
@@ -79,6 +79,21 @@
</div>
<?php
$staticList
=
[
[
'value'
=>
"one"
,
'key'
=>
"1"
],
[
'value'
=>
"two"
,
'key'
=>
"2"
],
[
'value'
=>
"three"
,
'key'
=>
"3"
],
[
'value'
=>
"four"
,
'key'
=>
"4"
],
[
'value'
=>
"five"
,
'key'
=>
"5"
],
[
'value'
=>
"six"
,
'key'
=>
"6"
],
[
'value'
=>
"seven"
,
'key'
=>
"7"
],
];
$staticListSafeJson
=
htmlentities
(
json_encode
(
$staticList
),
ENT_QUOTES
,
'UTF-8'
);
?>
<form
id=
"myForm"
class=
"form-horizontal"
data-toggle=
"validator"
>
...
...
@@ -89,7 +104,9 @@
<div
class=
"col-md-6"
>
<input
id=
"dropdown1"
type=
"text"
class=
"form-control qfq-typeahead"
name=
"dropdown1"
data-typeahead-sip=
"abcde"
data-typeahead-minlength=
"1"
data-typeahead-limit=
"3"
>
data-typeahead-sip=
"abcde"
data-typeahead-minlength=
"1"
data-typeahead-limit=
"3"
data-typeahead-tag-static-list=
"
<?php
echo
$staticListSafeJson
;
?>
"
>
</div>
</div>
...
...
@@ -102,7 +119,8 @@
<div
class=
"col-md-6"
>
<input
id=
"dropdown2"
type=
"text"
class=
"form-control qfq-typeahead"
name=
"dropdown2"
data-typeahead-sip=
"abcdef"
data-typeahead-limit=
"10"
data-typeahead-minlength=
"1"
data-typeahead-pedantic=
"true"
required
>
data-typeahead-pedantic=
"true"
required
data-typeahead-tag-static-list=
"
<?php
echo
$staticListSafeJson
;
?>
"
>
</div>
<div
class=
"col-md-4"
>
...
...
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