Given a drop down list, is there any way to subscribe a javascript even which will be fired when a new item is added to the list?
I’d like something like the following to work
$('select').itemAdded(function(value, text) { alert(text + ' has just been added to the list of options'); }); $('select').append($('<option></option').val('1').html('Something')); //results in alert of 'Something has just been added to the list of options'
This should work for all browsers (including explorer, which is a bugger about this sort of thing).
EDIT: I should probably stop being slack and give you the full code to make this work as a jQuery plugin.