I have the following code, which I want to load values on a selection change, and also do the selection load initially (since FF 'saves' the last value of the drop down under certain circumstances).
The select part of the function works correctly, but for some reason when calling load2
directly the value of $('#select1').value
is undefined
, even though when I check the DOM in Firebug right after load select1.value
has a value.
How can I run the load2
function after select1.value
is ready? What event will tell me when all the elements of $('#select1')
have been initialized?
$(document).ready(function() {
//Setup change hook
$('#select1').change(function(event) {
//Remove the old options right away
$('#select2').find('option').remove();
//Load the new options
load2(this.value);
});
//Do load for current value
load2($('#select1').value);
});