You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

  1. window.addEventListener("load", function() {
  2. (function($) {
  3. $(function() {
  4. // selfbuy section
  5. var selectField_selfbuy = $('#id_selfbuy'),
  6. verified_selfbuy_div = $('#id_selfbuy_give_data').parent().parent(),
  7. verified_selfbuy = $('#id_selfbuy_give_data'),
  8. data_selfbuy_div = $('#id_selfbuy_data').parent().parent(),
  9. data_selfbuy = $('#id_selfbuy_data');
  10. // make checked to get through the required
  11. function toggleVerified_selfbuy(value) {
  12. if (value === "FALSE") {
  13. verified_selfbuy_div.show();
  14. data_selfbuy_div.show();
  15. data_selfbuy.val("");
  16. verified_selfbuy.prop("checked", false);
  17. } else {
  18. verified_selfbuy_div.hide();
  19. data_selfbuy_div.hide();
  20. data_selfbuy.val("NONE");
  21. verified_selfbuy.prop("checked", true);
  22. }
  23. }
  24. // show/hide on load based on existing value of selectField
  25. toggleVerified_selfbuy(selectField_selfbuy.val());
  26. // show/hide on change
  27. selectField_selfbuy.change(function() {
  28. toggleVerified_selfbuy($(this).val());
  29. });
  30. });
  31. })(django.jQuery);
  32. });