/** * 处理双击编辑 */ function edit() { if($(".edit").length) { $(".edit").each(function() { $(this).bind('dblclick', function() { var col = $(this).attr('data-col'); var url = $(this).attr('data-url'); var id = $(this).attr('data-id'); var type = $(this).attr('data-type'); var html = $(this).text(); if(html.indexOf('input') == -1) { $(this).html(''); var self = $(this); self.find("#edit").blur(function() { var value = self.find("#edit").val(); if(!value) { alert('不能为空'); return; } if($(this).find(".edit-content").length) { $(this).find(".edit-content").html(value); } else { self.attr('data-content', value); } self.html(value); $.post(url, {value:value,id:id,type:type,col:col}, function(t) { //notify('修改成功'); }) }) } }); }) } } $(function() { edit(); });