I am trying to implement a combobox on a form that have his select
fields loaded in ajax.
I want to call :
$('.combobox').combobox();
When a new combobox is ready.
Currently, I put this in my ajax response :
<script type="text/javascript">
$(document).ready(function() {
$('.combobox').combobox();
});
</script>
This works but looks bad in term of resources. So I was looking for a better way to handle ready
events.
I tried :
$('.combobox').live('ready', function() {
$(this).combobox();
});
But read later that live()
does not support ready
event.
Then, I tried :
$('body').delegate('.combobox', 'ready', function() {
$(this).combobox();
});
But it doesn't work too.
So here is the question: what is the best way to handle current and future ready events on a selector in jquery?