position_form.html
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<script type="text/javascript">
$(function(){
//attach autocomplete
$('input#id_filtered_positions').autocomplete({
appendTo: "#add-table-elem-dialog",
//define callback to format results
source: function(req, add){
//pass request to server
$.getJSON(ajax_position_lookup, req, function(data) {
//create array for response objects
var suggestions = [];
$.each(data['result'], function(i, val){
suggestions.push(val[0]);
});
//pass array to callback
add(suggestions);
});
},
});
});
</script>
<form class="position-add-form" method="post"> {% csrf_token %}
{{ form.as_p }}
<p class="lexeme-save">
<button type="submit" id="add-position-submit">
Zapisz
</button>
<button type="reset" id="add-position-cancel">
Anuluj
</button>
</p>
</form>