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