1,zendframework 中的action将数据,通过以下方式进行输出变量
$result=$result?$result:array();
$this->view->assign('classinfo', $result);
$this->view->assign('classinfojson', json_encode($result));
$this->view->display("crm_custom/custom_class/class_list.html");
2,有smarty 模板的
<script>
var classdata={/literal}{$classinfojson}{literal};
</script>
3,把 html 进行拼接
var temphtml='';
for( var i in classdata){
temphtml += '<li id="j_class_li_name_'+classdata[i]["id"]+'"rel="'+classdata[i]["id"]+'" class="j_class">';
temphtml += '<a id ="j_class_name_'+classdata[i]["id"]+'" class="text" href="javascript:void(0);">'+classdata[i]["name"]+'<i class="after"></i></a>';
temphtml += '<div class="groups_edit">';
temphtml += '<a class="groups_tip" data-toggle="modal" href="#editClassModal">';
temphtml += '<i class="icon_pencil j_class_editname" rel="'+classdata[i]["id"] +'" value ="'+classdata[i]["name"]+'" title="修改"></i>';
temphtml += '</a>';
temphtml +='<a class="groups_tip j_class_delclass" rel="'+classdata[i]["id"]+'"><i class="icon_cross" title="删除"></i></a>';
temphtml +='</div>';
temphtml +='</li>';
}
4,使用jquery进行获取某标签 加入 html
$('.bluebg').html(temphtml);