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.

52 lines
1.5 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. // make checked to get through the required
  9. function toggleVerified_selfbuy(value) {
  10. if (value === "FALSE") {
  11. verified_selfbuy_div.show();
  12. verified_selfbuy.prop("checked", false);
  13. } else {
  14. verified_selfbuy_div.hide();
  15. verified_selfbuy.prop("checked", true);
  16. }
  17. }
  18. // show/hide on load based on existing value of selectField
  19. toggleVerified_selfbuy(selectField_selfbuy.val());
  20. // show/hide on change
  21. selectField_selfbuy.change(function() {
  22. toggleVerified_selfbuy($(this).val());
  23. });
  24. var selectField = $('#id_variant'),
  25. verified = $('#id_url_of_pic').parent().parent();
  26. function toggleVerified(value) {
  27. if (value === 'PIC') {
  28. verified.show();
  29. } else {
  30. verified.hide();
  31. }
  32. }
  33. // show/hide on load based on existing value of selectField
  34. toggleVerified(selectField.val());
  35. // show/hide on change
  36. selectField.change(function() {
  37. toggleVerified($(this).val());
  38. });
  39. });
  40. })(django.jQuery);
  41. });