My HTML (not dynamic) looks like this:
<select id="domain" class="marketplace">
<option>United States</option>
...
</select>
This works:
$("#domain").on("change", function() {
$("#domain").attr("disabled", "disabled");
/* do ajaxy stuff */
$("#domain").removeAttr("disabled");
});
$("select.marketplace").on("change", function() { /* do some general stuff */});
This does not:
$("#domain").on("change", function() {
$("#domain").attr("disabled", "disabled");
/* do ajaxy stuff */
$("#domain").removeAttr("disabled");
});
$(document).on("change", "select.marketplace", function() { /* do some general stuff */});
Removing the $("#domain").attr("disabled", "disabled");
call restores the functionality of the $(document).on()
delegation, so it appears events do not bubble when an element is disabled, regardless of how the event is triggered (i.e. neither by .trigger
nor .triggerHandler
nor by user interaction). However, I do not understand why, as neither handler returns anything or makes any calls to prevent event propagation, and the jQuery documentation makes no mention of the "disabled" attribute having any effect on propagation. What am I missing here?