Subscribe selection fix

This commit is contained in:
Bernie Chiu 2013-11-22 17:42:11 +08:00
parent d07b8f4c09
commit 849cfa2076
1 changed files with 16 additions and 8 deletions

View File

@ -3,15 +3,15 @@
<% end %>
<script type="text/javascript">
var checkboxes = $('.checkbox input');
var $checkboxes = $('.checkbox input');
$(document).ready(function() {
var categories = <%= @categories.to_json.html_safe %>;
for (var i = 0; i < checkboxes.length; i++) {
for (var i = 0; i < $checkboxes.length; i++) {
if ($.inArray(checkboxes[i].value, categories) != -1) {
checkboxes[i].checked = true;
if ($.inArray($checkboxes[i].value, categories) != -1) {
$checkboxes[i].checked = true;
} else {
continue;
}
@ -19,12 +19,20 @@ $(document).ready(function() {
});
checkboxes.on('click', function() {
if (checkboxes[0].checked == true) {
for (var i = 1; i < checkboxes.length; i++) {
checkboxes[i].checked = false;
$('#announcement_feed_categories_').on('click', function() {
if ($checkboxes[0].checked == true) {
for (var i = 1; i < $checkboxes.length; i++) {
$checkboxes[i].checked = false;
}
}
});
$checkboxes.on('click', function() {
for (var i = 1; i < $checkboxes.length; i++) {
if ($checkboxes[i].checked == true) {
$checkboxes[0].checked = false
}
}
});
</script>