forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage-community-list.js
More file actions
36 lines (33 loc) · 1.43 KB
/
manage-community-list.js
File metadata and controls
36 lines (33 loc) · 1.43 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
$(document)
.ready(function () {
$("[name=rule_type]")
.on("click change keypress", function () {
var form = $(this)
.closest("form");
var ruleType = $(this)
.val();
var emptyForms = $(".empty-forms");
var currentFormContent = form.find(".form-content-placeholder .rule-type");
if (!ruleType || !currentFormContent.hasClass(ruleType)) {
// move previous back into the collection
if (currentFormContent.length > 0)
emptyForms.append(currentFormContent);
else
currentFormContent.html(""); // make sure it's empty
// insert new
if (ruleType)
form.find(".form-content-placeholder")
.append(emptyForms.find("." + ruleType));
}
});
$("[name=rule_type]")
.each(function () {
// don't trigger the handler if we have a form with errors
var placeholderContent = $(this)
.closest("form")
.find(".form-content-placeholder >");
if (placeholderContent.length == 0 || placeholderContent.hasClass("rule-type"))
$(this)
.trigger("change");
});
});