How to add content to elements as they are created by a plugin?
I'm using a plugin (asmSelect) that dynamically generates list items as the user chooses options from a select. I want to add additional dynamic content to each of the list items as they are created. How is this best accomplished? I thought I could delegate a 'load' event for the list items, but it looks like load events don't fire for content that's generated by JavaScript. (Delegating a 'click' event works, so I know I've got the code correct.)
What I want to do is basically equivalent to:
- $('#testform').delegate('.asmListItem', 'load', function(){
- custom_content = '<span>' + [calculated result] + '</span>';
- $(this).append(custom_content);
- });
Modifying the plugin to take the dynamic content doesn't seem like an option. The additional content will be different every time, so I can't just pass it as an argument when I initialize the plugin.