0

Using ABP Commercial and in a generated page I have 2 checkboxes, but I am unable to get the change event of them.

Here is the generated code for the checkbox

<input type="checkbox" data-val="true" data-val-required="The Permanent Resident Australia field is required." id="Prospectus_IsPermanentResidentAustralia" name="Prospectus.IsPermanentResidentAustralia" value="true" class="custom-control-input ">

I have tried a number of ways to get the change event.

$("#Prospectus_IsPermanentResidentAustralia").change(function () {
  $('#permAusDate').toggle();
    });

  $('#Prospectus_IsPermanentResidentAustralia').on("change", function () {
            $('#permAusDate').toggle();
   
});

Also tried it this way.

$(('#IsInternational').val).change(function () {
    if (this.checked != true) {
        $("#InternationalStudent").hide();
    }
    else {
        $("#InternationalStudent").show();
    }
});

If I do this below, it works - the toggle is succesful - but naturally throws an error as change isn't a function as its missing the ()

 var permResidentAus = $('Prospectus.IsPermanentResidentAustralia').change;
$('permResidentAus ').on("change", function () {
           $('#permAusDate').toggle();
 
});

What am I missing in ABP?

jazb
  • 5,498
  • 6
  • 37
  • 44
netchicken
  • 355
  • 2
  • 7
  • 20
  • Does this answer your question? [jQuery checkbox change and click event](https://stackoverflow.com/questions/7031226/jquery-checkbox-change-and-click-event) – jazb Jan 13 '21 at 07:47
  • 1
    Can you be generating the page dynamically? Did you try $(document).on('change','#Prospectus_IsPermanentResidentAustralia', function(e){ $('#permAusDate').toggle();}) – gterdem Jan 14 '21 at 00:21
  • this has nothing to do with ABP. You can use jQuery `on` `change` to subscribe the change event. – Alper Ebicoglu Jan 26 '21 at 13:37

0 Answers0