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.

48 lines
1.4 KiB

  1. window.addEventListener("load", function() {
  2. (function($) {
  3. $(function() {
  4. var selectField_selfbuy = $('#id_selfbuy'),
  5. verified_selfbuy_div = $('#id_selfbuy_give_data').parent().parent(),
  6. verified_selfbuy = $('#id_selfbuy_give_data');
  7. function toggleVerified_selfbuy(value) {
  8. if (value === "FALSE") {
  9. verified_selfbuy_div.show();
  10. verified_selfbuy.prop("checked", false);
  11. } else {
  12. verified_selfbuy_div.hide();
  13. verified_selfbuy.prop("checked", true);
  14. }
  15. }
  16. // show/hide on load based on existing value of selectField
  17. toggleVerified_selfbuy(selectField_selfbuy.val());
  18. // show/hide on change
  19. selectField_selfbuy.change(function() {
  20. toggleVerified_selfbuy($(this).val());
  21. });
  22. var selectField = $('#id_variant'),
  23. verified = $('#id_url_of_pic').parent().parent();
  24. function toggleVerified(value) {
  25. if (value === 'PIC') {
  26. verified.show();
  27. } else {
  28. verified.hide();
  29. }
  30. }
  31. // show/hide on load based on existing value of selectField
  32. toggleVerified(selectField.val());
  33. // show/hide on change
  34. selectField.change(function() {
  35. toggleVerified($(this).val());
  36. });
  37. });
  38. })(django.jQuery);
  39. });