是否有可能JavaScript不适用于通过ajax请求创建的元素? 实际上,我有一个像父母和孩子一样的元素树与更多级别的部门。ajax在javascript创建元素
我有索引页上的根元素上点击,我可以retrive孩子低谷这个请求:
var get_children = function() {
pid = $(this).attr("id");
//var parentid = pid
// store value in data variable
var data = { par: pid };
$.getJSON("/holz/children/",data,
function(data){
//remove the box if it already exists
$("#parid-" + pid).remove();
// Add the messages div to the container
$("#container").append("<div class='box' id='parid-" + pid + "'></div>");
//create the id set for the box
boxid = "#parid-"+pid
//insert the elements one after each other with the id set to the elements pk
$.each(data, function(i,item){
$(boxid).append('<p><a '+'id="'+item.pk+'"'+' class="element" href="#">'+item.fields.title +' (id = '+ item.pk+')'+'</a>'+'</p>');
});
}
);
return false;
};
的问题是,由于请求doenst适用于我得到的元素我不能走得更深从第一个请求。 ajax请求调用一个django视图,该视图应该(并且它在第一个元素上)并返回一个json响应,我使用它来为子项创建一个框。
我在做什么错?
THX
约定的,动态添加的元素没有连线,因为连线代码已经运行,所以您必须使用live才能确保添加的元素也已连线。 – 2010-01-25 19:40:04
thx球员......这工作。 – aschmid00 2010-01-26 07:06:29