JQuery delegate command does not seem to be working

56 Views Asked by At

I have a fieldset that contains a bunch of input elements and which is initially collapsed when displayed to the user. I would like to attach an event handler on the a drop down list that is contained in the fieldset but I seem to be having trouble accomplishing this. I am using jQuery 1.5 and this is the code that I am using:

// Add a change listener to the specified select box.
$(document).delegate("select[name='type_config[format]']", 'change', function() {
    var selectedValue = $("select[name='type_config[format]']").find(":selected").val();
    console.log("the value you selected: " + selectedValue);
});

I thought using delegate would accomplish this as drop down is not initially visible. However when I change the selection in the drop down list nothing happens. I know the selector is correct as I tested it out in the console when the drop down is visible. Any ideas what I am doing wrong (or what I may be overlooking)?

0

There are 0 best solutions below