Commit 72cc6524bb1456432489834e548863a059a4ffde
1 parent
e14046bd
Exists in
master
and in
5 other branches
Finished create link template [Issue:#120]
Showing
1 changed file
with
41 additions
and
15 deletions
Show diff stats
links/templates/links/create_link.html
1 | +{% load widget_tweaks i18n %} | |
2 | + | |
1 | 3 | <!--MODAL CREATE LINK--> |
2 | -<div class="modal fade" id="createLinksModal" tabindex="-1" role="dialog" aria-labelledby="createLink" style="display: none;"> | |
4 | +<div class="modal fade" id="createLinksModal" tabindex="-1" role="dialog" aria-labelledby="createLink"> | |
3 | 5 | <div class="modal-dialog" role="document"> |
4 | 6 | <div class="modal-content"> |
5 | 7 | <div class="modal-header"> |
... | ... | @@ -8,25 +10,49 @@ |
8 | 10 | </div> |
9 | 11 | <div class="modal-body"> |
10 | 12 | <!-- Card --> |
11 | - <div class="form-group is-empty"> | |
12 | - <label class="control-label" for="inputDefault">Name</label> | |
13 | - <input type="text" class="form-control" id="inputDefault"> | |
14 | - </div> | |
15 | - <div class="form-group is-empty"> | |
16 | - <label class="control-label" for="inputDefault">Url</label> | |
17 | - <input type="text" class="form-control" id="inputDefault"> | |
18 | - </div> | |
19 | - <div class="form-group is-empty"> | |
20 | - <label class="control-label" for="inputDefault">Descrição</label> | |
21 | - <textarea class="form-control" rows="3"></textarea> | |
22 | - </div> | |
13 | + <form method="post" action="" id="form-link" enctype="multipart/form-data"> | |
14 | + {% csrf_token %} | |
15 | + {% for field in form %} | |
16 | + {% if field.field.required %} | |
17 | + <label for="{{ field.auto_id }}">{{ field.label }}<span>*</span></label> | |
18 | + {% else %} | |
19 | + <label for="{{ field.auto_id }}">{{ field.label }}</label> | |
20 | + {% endif %} | |
21 | + {% render_field field class='form-control' %} | |
22 | + {% endfor %} | |
23 | 23 | <div class="form-group"> |
24 | 24 | <a href="javascript:void(0)" class="btn btn-raised btn-default" data-dismiss="modal">Cancel</a> |
25 | - <a href="javascript:void(0)" class="btn btn-raised btn-primary">Submit</a> | |
26 | - </div> | |
25 | + <button class="btn btn-raised btn-primary" type="submit">Submit</button> | |
26 | + </div> | |
27 | 27 | <!-- .end Card --> |
28 | 28 | </div> |
29 | 29 | </div> |
30 | 30 | </div> |
31 | 31 | </div> |
32 | 32 | <!-- EndModal --> |
33 | + | |
34 | +{# // <script src="{% static '/links.js' %}"></script> #} | |
35 | +<script type="text/javascript"> | |
36 | + $("#form-link").submit(function(event) { | |
37 | + var data = new FormData($('#form-link').get(0)); | |
38 | + $.ajax({ | |
39 | + url: "{% url 'course:links:create_link' topic.slug %}", | |
40 | + type: $("#form-link").attr('method'), | |
41 | + data: data, | |
42 | + cache: false, | |
43 | + processData: false, | |
44 | + contentType: false, | |
45 | + success: function(data) { | |
46 | + $('#createLinksModal').modal('hide'); | |
47 | + $('#list-topic{{ topic.id }}-links').append(data); | |
48 | + $('#list-topic{{ topic.id }}-links-edit').append(data); | |
49 | + }, | |
50 | + error: function(data){ | |
51 | + $('.erro').html(data.responseText); | |
52 | + $('.modal-backdrop').remove(); | |
53 | + $('#createLinksModal').modal(); | |
54 | + } | |
55 | + }); | |
56 | + event.preventDefault(); | |
57 | + }); | |
58 | +</script> | ... | ... |