I have a website with jQuery and jQuery UI. I have a Javascript function:
function ToButton()
{
$(".ToButton").button();
}
This function runing after the page load and change all elements with class "ToButton".
Also I change HTML code when user press a button. E.g.:
$("body").append('<span class="ToButton">Test Button</span>');
And I want to run ToButton function to this new element too, but live or delegate methods in jQuery don't have "show" or "create" event type. So I need call function ToButton() after all HTML code changes.
Can you help me, how I can delegate ToButton function to all elements?
You need to do this manually after appending new elements. Delegates and live events are only for events that bubble up.
However, you could make life more easier by listening for some of the DOM events to get a notification when a new element has been added.