Skip to content

Commit 80e8cb1

Browse files
committed
add js logic for menu
1 parent e1ab5b5 commit 80e8cb1

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

adminlteui/templates/adminlte/menu_change_form.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@
22

33
{% block extrajs %}
44
{{ block.super }}
5+
56
<script>
67
django.jQuery('#id_content_type').select2();
8+
$.fn.link_type = function () {
9+
$(this).change(function () {
10+
var $field = $(this);
11+
var $option = $field.find('option:selected');
12+
if ($option.val() !== "0") {
13+
$('.field-content_type').hide();
14+
} else {
15+
$('.field-content_type').show();
16+
}
17+
if ($option.val() === "3") {
18+
$('.field-link').hide();
19+
} else {
20+
$('.field-link').show();
21+
}
22+
});
23+
$(this).trigger('change');
24+
};
25+
$('#id_link_type').link_type();
726
</script>
827
{% endblock %}
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
{% extends "admin/tree_change_list.html" %}
22
{% load i18n %}
33
{% block object-tools-items %}
4-
<button class="btn btn-danger">{% trans 'Exchange Menu' %}</button>
5-
<!--TODO-->
4+
<button id="exchange_menu" class="btn btn-danger">{% trans 'Exchange Menu' %}</button>
65
{{ block.super }}
6+
{% endblock %}
7+
8+
{% block extrajs %}
9+
{{ block.super }}
10+
<script>
11+
$(function () {
12+
$('#exchange_menu').click(function () {
13+
$.get('{% url "admin:exchange_menu" %}', function (response) {
14+
console.log(response);
15+
if (response.message === 'success') {
16+
window.location.reload();
17+
}
18+
})
19+
})
20+
});
21+
</script>
722
{% endblock %}

0 commit comments

Comments
 (0)