javascript - issue with insertBefore() -



javascript - issue with insertBefore() -

i got little object has append new rows table.. works fine in cases, if there table within of rows (in "root" table) object doesn't append proper table!?

i have been doing bit of debugging , found line goes wrong.. if debug set , line insertbefore() omitted object appends proper table

var list = new function(){ this.append_row = function(row, tbl, index){ if(debug){ index = -1; } if(index == 0){ row.prependto(tbl); } else if(index > 0){ var elm = $('tr', tbl); if(elm.length > index){ row.insertbefore(elm.eq(index)); // issue in line } else{ row.appendto(tbl); } } else{ row.appendto(tbl); } }; }

it because this:

var elm = $('tr', tbl);

...is equivalent this:

var elm = $(tbl).find('tr');

so locate nested <tr> elements in nested <table>.

so this:

var elm = $(tbl.rows); // if `tbl` dom element

or this:

var elm = $(tbl[0].rows); // if `tbl` jquery object

now elm reference rows of tbl, , not nested <table> elements.

javascript jquery

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -