Using .load
, I'm loading the following content into #step_2
div:
<div id="step_2">
Select a subcategory:
<select id="subcategory_id" name="subcategory_id">
<option value="0">All subcategories</option>
<option value="68">Cool</option>
<option value="15">Cooler</option>
<option value="74">Excellent</option>
</select>
</div>
I'm then trying to detect when user selects something:
$("#subcategory_id").on("change", function(){
alert( 'Success!' );
});
but with no success. Does anyone see what I'm doing wrong? Help greatly appreciated.
NOTES:
Here's the full CSS path as seen by FireBug:
html.js body div#container div#main form div#step_2 select#subcategory_id
Here's the full Javascript file, if context matters:
$(document).ready(function() {
$("#category_id").change(function() {
$("#spinner").show();
$("#step_2").load("process.php?selected=category", { value: $(this).val() }, function() {
// Do something to say the data has loaded sucessfully
$("#spinner").hide();
});
});
$("#subcategory_id").on("change", function(){
alert( 'Success!' );
});
});