EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: nyr_jack on October 29, 2012, 08:48:42 PM



Title: Why remove all nodes occur bug
Post by: nyr_jack on October 29, 2012, 08:48:42 PM
var roots = $('#targetTree').tree('getRoots');
  for(var i = 0; i < roots.length; i++){
  $('#targetTree').tree('remove',roots.target);
}

Why occur bug with message '0.target is null or ...'


Title: Re: Why remove all nodes occur bug
Post by: sphsyv on October 29, 2012, 10:19:37 PM
var roots = $('#targetTree').tree('getRoots');
  for(var i = 0; i < roots.length; i++){
  $('#targetTree').tree('remove',roots.target);
}

Why occur bug with message '0.target is null or ...'

当你remove第一个后,这个roots的索引就改变了,所以会出错。