Radio button change even not firing

I have this html which was created dynamically based on data from our database. I am trying to create a wizard so that when the user clicks a radio button, I call a webservice using ajax, and create another list of radio buttons for the user to select from. The initial page load works fine, but when I create the dynamic radio button list that is where I am having problems with the events firing. Do I have to reload the document, or a specific div to get this to work?

I would like to trap the “change” event when one of these radio buttons is selected. The jQuery below is not capturing the event. Any suggestions as to what I am doing wrong?

Read More

HTML:

<input name="productModel" id="Basic-jacketCustom" type="radio" value="Basic jacket"><label for="Basic-jacketCustom">Basic jacket</label>
<input name="productModel" id="Platinum-jacketCustom" type="radio" value="Platinum jacket"><label for="Platinum-jacketCustom">Platinum jacket</label>
<input name="productModel" id="Platinum-Pro-jacketCustom" type="radio" value="Platinum Pro jacket"><label for="Platinum-Pro-jacketCustom">Platinum Pro jacket</label>
<input name="productModel" id="Riding-jacketCustom" type="radio" value="Riding jacket"><label for="Riding-jacketCustom">Riding jacket</label>

jQuery:

$('input[name="productModel"]').change(function() {    alert("Event
 Fires"); });

Related posts

Leave a Reply

1 comment

  1. What do you mean with “dynamically created”? Are you pushing the input to dom after the page load? If yes, you have to use Event Delegation. Try the following example:

    $('body').on('change', 'input[name="productModel"]', function() {
      alert("Event Fires");
    });