Problem calling .menu() on injected (dynamically created) HTML

Problem calling .menu() on injected (dynamically created) HTML

Hi,

I have dynamically created HTML like this:

var str = '<ul id="menu1">
str += '<li><a href="#">Item1</a></li>';
str += '<li><a href="#">Item2</a></li>';
str += '</ul>';

$('#div1').html( str );

// Insert jQueryUI
$('#menu1').menu();


The problem is, this doesn't work. If I make the <ul></ul> in static HTML, then it works.

Can someone point me in the right direction?

Thanks !!