prepared autocomplete

This commit is contained in:
Tim Krehan 2019-05-19 20:31:37 +02:00
parent 1c18fe20a0
commit 7b700cb820
5 changed files with 14 additions and 13 deletions

1
bin/bootstrap.autocomplete.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -4,15 +4,14 @@ $(document).ready(function () {
$("input[type=number]").on("focus", function () { $(this).select(); }); $("input[type=number]").on("focus", function () { $(this).select(); });
$("input[type=text]").on("focus", function () { $(this).select(); }); $("input[type=text]").on("focus", function () { $(this).select(); });
// $(".ingredientName").on("focus", function () { // implement autocomplete with https://bootstrap-autocomplete.readthedocs.io/en/latest/#
// autocomplete(this, values); $(".autocomplete-ingredient").autoComplete(
// }); {
// $(".ingredientName").keydown(function (x) { resolverSettings: {
// if ((x.keyCode == 9) && ($(this).parent().parent().next().prop("class") != $(this).parent().parent().prop("class"))) { url: '/api/recipes/auto'
// $(this).parent().parent().find(".addIngredient").click(); }
// } }
// }); );
// $(".ingredientAmount").on("focus", function () { $(this).select(); });
}); });

View file

@ -12,7 +12,7 @@
$additionalInput = ""; $additionalInput = "";
} }
?> ?>
<!-- <script src="/bin/autocomplete.js" charset="utf-8"></script> --> <script src="/bin/bootstrap.autocomplete.js" charset="utf-8"></script>
<script src="/bin/manageRecipe.js" charset="utf-8"></script> <script src="/bin/manageRecipe.js" charset="utf-8"></script>
<?php echo $script; ?> <?php echo $script; ?>
<div class="container mt-5"> <div class="container mt-5">
@ -55,7 +55,7 @@
?> ?>
</select> </select>
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" name="ingredient[1][Name]" placeholder="Zutat" required> <input type="text" class="autocomplete-ingredient form-control" name="ingredient[1][Name]" placeholder="Zutat" autocomplete="off" required>
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text p-0"><button onclick="removeItem(this);" class="removeItem fas fa-trash-alt bg-transparent rounded-right border-0 p-2 pl-3 pr-3 text-danger"></button></span> <span class="input-group-text p-0"><button onclick="removeItem(this);" class="removeItem fas fa-trash-alt bg-transparent rounded-right border-0 p-2 pl-3 pr-3 text-danger"></button></span>
</div> </div>

View file

@ -180,8 +180,9 @@
$values = array(); $values = array();
$result = $mysqli->query("SELECT Name FROM Zutat ORDER BY Name ASC"); $result = $mysqli->query("SELECT Name FROM Zutat ORDER BY Name ASC");
while($item = $result->fetch_assoc()){ while($item = $result->fetch_assoc()){
echo $item["Name"]."||"; array_push($values, $item["Name"]);
} }
print_r(json_encode($values));
$mysqli->close(); $mysqli->close();
} }