页面处理,可将html代码直接写入script区域,然后将值直接赋到html代码中
如下:
js:
function getAccount() {
jQuery_1_7_2.ajax({
url : contextPath + '/tops/findUser.jsonp',
dataType : 'jsonp',
data : dataKeys,
async : false,
cache : false,
success : function(data) {
var template = jQuery_1_7_2('#render_setting').html();
var html = Mustache.render(template, data);
jQuery_1_7_2('#userSet .dropdown').append(html);
},
error : function(e) {
}
});
}
script:
<script type="text/html" id="render_setting">
<div class="dropdown-layout">
<div class="topInfo">
<img src="{{^result.userPic}}$imageContextPath/images/head/default_user.png{{/result.userPic}}{{#result.userPic}}{{result.userPic}}{{/result.userPic}}" width="35" height="35" alt="">
<span class="mg-l10" title="{{^result.userName}}$!tRegUserComplex.tregUser.loginName{{/result.userName}}{{#result.userName}}{{result.userName}}{{/result.userName}}">{{^result.userName}}$!tRegUserComplex.tregUser.loginName{{/result.userName}}{{#result.userName}}{{result.userName}}{{/result.userName}}</span>
</div>
<p><a href="javascript:personalData();" title="个人资料">个人资料</a></p>
<p><a href="javascript:companyData();" title="企业资料">企业资料</a></p>
<p><a href="javascript:tradeCenter();" title="交易中心">交易中心</a></p>
<p><a href="javascript:pwdData();" title="密码修改">密码修改</a></p>
<p class="logout"><a href="javascript:logoutData();" title="退出">退出</a></p>
</div>
</script>