$(document).ready(function() { //列表下拉 $('img[ds_type="flex"]').click(function() { var status = $(this).attr('status'); if (status == 'open') { var pr = $(this).parent('td').parent('tr'); var id = $(this).attr('fieldid'); var obj = $(this); $(this).attr('status', 'none'); //ajax $.ajax({ url: ADMINSITEURL + '/Goodsclass/goods_class.html?ajax=1&gc_parent_id=' + id, dataType: 'json', success: function(data) { var src = ''; for (var i = 0; i < data.length; i++) { var tmp_vertline = ""; src += ""; src += ""; //图片 if (data[i].have_child == 1) { src += " "; } else { src += " "; } src += ""; //排序 src += " " + data[i].gc_sort + ""; //名称 src += ""; for (var tmp_i = 1; tmp_i < (data[i].deep - 1); tmp_i++) { src += tmp_vertline; } if (data[i].have_child == 1) { src += " "; } else { src += " "; } src += " " + data[i].gc_name + ""; //新增下级 if (data[i].deep < 3) { src += "新增下级"; } src += ""; //是否显示 /*src += ""; if(data[i].gc_show == 0){ src += ""; }else{ src += ""; } src += ""; */ //类型 src += "" + data[i].type_name + ""; //虚拟 if (data[i].gc_virtual == 1) { src += "虚拟"; } else { src += ""; } //操作 src += ""; src += "编辑"; src += " | 删除"; src += ""; src += ""; } //插入 pr.after(src); obj.attr('status', 'close'); obj.attr('src', obj.attr('src').replace("tv-expandable", "tv-collapsable")); $('img[ds_type="flex"]').unbind('click'); $('span[ds_type="inline_edit"]').unbind('click'); //重现初始化页面 $.getScript(ADMINSITEROOT + "/js/jquery.edit.js"); $.getScript(ADMINSITEROOT + "/js/jquery.goods_class.js"); }, error: function() { alert('获取信息失败'); } }); } if (status == 'close') { $(".row" + $(this).attr('fieldid')).remove(); $(this).attr('src', $(this).attr('src').replace("tv-collapsable", "tv-expandable")); $(this).attr('status', 'open'); } }) });