"maybe" = "peut-être" en français. ;) No, the problem is that no event is raised.
$("span[id]").click(function() { alert("Toto"); }); If I add an "alert (" toto "), it appears when I click on" item 2 "but not when I click on" Item 2-1 ". On 19 mai, 16:15, "#micah" <micah.a.sm...@gmail.com> wrote: > Is the extra '-' in span id="item-2-1" the issue? Should it be span > id="item 2-1"? > > How do you say maybe in french? :) > > On May 19, 9:00 am, mrkeyser <mathieu.develo...@gmail.com> wrote: > > > Hello, > > > I'm french, sorry for my English, thank you google translation! ;) > > > I'd like to make ajax calls to load sub-nodes in my treeview. > > I have the following tree: > > > Tree HTML : > > > <ul id="tree"> > > <li id="1"><span>Item 1</span></li> > > <li id="2"><span id="item-2">Item 2</span></li> > > <li id="3"><span>Item 3</span></li> > > </ul> > > > Method JS : > > > $("span[id]").click(function() { > > var toto = $(this).parent(); > > if (toto.find(">ul").length == 0) { > > var id = $(this).attr("id").substring("item-".length); > > $.post("/Export/GetChildItem", { "id": id }, function(data) { > > var branches = $(data).appendTo("#" + id); > > $("#tree").treeview({ > > add: branches > > }); > > }); > > } > > > }); > > > Result : > > > <ul id="tree"> > > <li id="1"><span>Item 1</span></li> > > <li id="2"><span id="item-2">Item 2</span> > > <ul> > > <li><span id="item-2-1">Item 2-1</span></li> > > <li><span>Item 2-2</span></li> > > </ul> > > </li> > > <li id="3"><span>Item 3</span></li> > > </ul> > > > When I click on "item 2", no problem. If I click on "item 2-1", no > > event, why? > > I've tried everything, I do not see... > > > Thanks