所以在按钮<button id="button" type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="Add a recipe">Add a recipe</button>
<!-- end of button -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">New Recipe</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="recipe-form" action="/pizza" method="POST">
<a id="userId" data-id=<%=user.id %>></a>
<input type="text" id="pizza-title" name="pizza-title" placeholder="title"><br>
<input type="text" id="pizza-recipe" name="pizza-recipe" placeholder="recipe"><br>
<label for="vegy1">Cucumber</label>
<input type="number" class="quant" name="vegy1" data-name="cucumber" min="0" max="3" value="0">
<label for="vegy2">Tomato</label>
<input type="number" class="quant" name="vegy2" data-name="tomato" min="0" max="3" value="0">
<label for="vegy3">Pineapple</label>
<input type="number" class="quant" name="vegy3" data-name="pineapple" min="0" max="3" value="0">
<label for="vegy4">Avocado</label>
<input type="number" class="quant" name="vegy4" data-name="avocado" min="0" max="3" value="0"><br>
<label for="vegy5">Eggplant</label>
<input type="number" class="quant" name="vegy5" data-name="eggplant" min="0" max="3" value="0">
<label for="vegy6">Olive</label>
<input type="number" class="quant" name="vegy6" data-name="olive" min="0" max="3" value="0">
<label for="vegy7">Onion</label>
<input type="number" class="quant" name="vegy7" data-name="onion" min="0" max="3" value="0">
<label for="vegy8">Mushroom</label>
<input type="number" class="quant" name="vegy8" data-name="mushroom" min="0" max="3" value="0"><br>
<label for="vegy9">Garlic</label>
<input type="number" class="quant" name="vegy9" data-name="garlic" min="0" max="3" value="0">
<label for="vegy10">Spinach</label>
<input type="number" class="quant" name="vegy10" data-name="spinach" min="0" max="3" value="0">
<label for="vegy11">Cilantro</label>
<input type="number" class="quant" name="vegy11" data-name="cilantro" min="0" max="3" value="0">
<label for="vegy12">Chicken</label>
<input type="number" class="quant" name="vegy12" data-name="chicken" min="0" max="3" value="0"><br>
<label for="vegy13">Anchovy</label>
<input type="number" class="quant" name="vegy13" data-name="anchovy" min="0" max="3" value="0">
<label for="vegy14">Bacon</label>
<input type="number" class="quant" name="vegy14" data-name="bacon" min="0" max="3" value="0">
<label for="vegy15">Sausage</label>
<input type="number" class="quant" name="vegy15" data-name="sausage" min="0" max="3" value="0">
<label for="vegy16">Beef</label>
<input type="number" class="quant" name="vegy16" data-name="beef" min="0" max="3" value="0"><br>
<label for="vegy17">Ham</label>
<input type="number" class="quant" name="vegy17" data-name="ham" min="0" max="3" value="0">
<label for="vegy18">Pepperoni</label>
<input type="number" class="quant" name="vegy18" data-name="pepperoni" min="0" max="3" value="0">
<label for="vegy19">Salami</label>
<input type="number" class="quant" name="vegy19" data-name="salami" min="0" max="3" value="0">
<label for="vegy20">Banana</label>
<input type="number" class="quant" name="vegy20" data-name="banana" min="0" max="3" value="0"><br>
<p id="totalCal"></p>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary addPizza">Add Recipe</button>
</div>
</form>
</div>
</div>
</div>
</div>
中它说的是什么,我相信这会覆盖我的输入标签的占位符,并且不知道为什么,如果我摆脱了它,它将起作用,但是h5新配方标题将为空白
<'class 'chessengine.admin.GameInline'>: (admin.E202) 'chessengine.Game' has more than one ForeignKey to 'chessengine.Player'.
答案 0 :(得分:0)
这是您代码的有效提琴,以后会尽可能添加一个
https://codepen.io/rodozlatan/pen/aXvqag
您能从那里更好地解释哪些部分没有按预期工作吗?
$('#autocomplete').autocomplete({
source: $('#autocomplete').data(getUsers), //`enter code here`
select: function (event, ui) {
$('#CareerManager').on("autocompleteselect", function (event, ui){
//`enter code here`
});
}
});
var getUsers = function () {
var users = [];
$.ajax({
url: "url?$select=Email",
headers: { Accept: "application/json;odata=verbose" },
dataFilter: function (data, type) {
return data;
},
success: function (data) {
var results = data.d.results;
try {
//Get properties from user profile Json response
for (var u = 0; u < results.length; u++) {
//Return Name and Email
//users.push(data.d.results[u].Title,
//data.d.results[u].Email);
users.push(data.d.results[u].Email);
}
autocomplete(document.getElementById("CareerManager"), users);
autocomplete(document.getElementById("Recruiter"), users);
autocomplete(document.getElementById("SeniorAssociate"), users);
autocomplete(document.getElementById("Principal"), users)
} catch (err2) {
//alert(JSON.stringify(err2));
}
},
error: function (jQxhr, errorCode, errorThrown) {
alert(errorThrown);
}
});
} //getUsers function ends
getUsers(); //function for autocomplete