How do I fix my broken jQuery change event?

Michael Sterling
Michael Sterling used Ask the Experts™
on
I recently upgraded from jQuery 1.11.1 to jQuery 3.0.0 and now  a simple change on a couple of radio buttons no longer works. How can I get this back to working as it should?

    <script type="text/javascript">
       jQuery(document).ready(function () {
            j$('#cmdCreateNewEvent').prop('disabled', 'disabled');

            $('#rdoSameDonor').change(function () {
                EnableCreateButton();
            });
            $('#rdoDifferentDonor').change(function () {
                EnableCreateButton();
            });
        });

        function EnableCreateButton() {
            $('#cmdCreateNewEvent').removeProp('disabled');
        }
    </script>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Line: 3
j$('#cmdCreateNewEvent').prop('disabled', 'disabled');
^
What's this

Open in new window

After you have fixed that check your console for errors.
This code works with 3.4.1
<input type="radio" name="radio1" id="rdoSameDonor"> rdoSameDonor
<input type="radio" name="radio1" id="rdoDifferentDonor"> rdoDifferentDonor

Open in new window

jQuery
<script>
jQuery(document).ready(function () {
  $('#cmdCreateNewEvent').prop('disabled', 'disabled');
  $('#rdoSameDonor').change(function () {
    EnableCreateButton();
  });
  $('#rdoDifferentDonor').change(function () {
    EnableCreateButton();
  });
});

function EnableCreateButton() {
  alert('Fired');
}
</script>

Open in new window

Michael SterlingWeb Applications Developer

Author

Commented:
Julian - I got it figured out and that was a mistake...
Michael SterlingWeb Applications Developer

Author

Commented:
This was my solution. Not sure if this was the best/better way to do this but it is working. I'll leave this open to "better" suggestions for a few days before I close it. It would be good to know other ways to make this work. Thanks in advance!

    <script type="text/javascript">
        jQuery(document).ready(function () {
            $('#cmdCreateNewEvent').prop('disabled', 'disabled');

            $('#rdoSameDonor').on('click', function () {
                if (this.checked)
                    EnableCreateButton();
            });
            $('#rdoDifferentDonor').on('click', function () {
                if (this.checked)
                    EnableCreateButton();
            });
        });

        function EnableCreateButton() {
            $('#cmdCreateNewEvent').attr("disabled", false);
        }
    </script>

Open in new window

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You don't need to do that .change() should work.

Here is a working sample http://www.marcorpsa.com/ee/t3660.html
Michael SterlingWeb Applications Developer

Author

Commented:
Ok. I'll keep trying ".change()". For some reason though, its not enabling my button so that I can click it and I don't know why. Maybe it works for the version of jQuery that you're using but for 3.0.0 its not working. Not sure why.
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Do you have a link?
Michael SterlingWeb Applications Developer

Author

Commented:
I don't but I got it working.
Michael SterlingWeb Applications Developer

Author

Commented:
Thanks for your help.
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You are welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial