主题 : $("#itemsContainer"+ind).append(tpl(ind,index++));
级别: 白丁
UID: 67021
积分:8 加为好友
威望: 1 精华: 0
主题:1 回复:8
注册时间:2014-09-14
在线时长:0
1#   发表于:2014-10-07 10:25:52  IP:111.252.*.*
各位大神,$("#itemsContainer"+ind).append(tpl(ind,index++));是怎么实现的吗?
<textarea id="subTopicTpl" style="display:none;">
<div class="items">
<@s.m "cmsVoteItem.title"/>: <input type="text" name="subtitle{0}" style="width:300px"/>
&nbsp; 
<@s.m "cmsVoteItem.priority"/>: <input type="text" name="subPriority" value="{0}" style="width:30px"/>
<@s.m "cmsVoteTopic.type"/>: <input type="radio" name="typeId{0}" value="1" onclick="changeAddItemButton({0},this.value)" checked="checked">

<@s.m "cmsVoteTopic.type.single"/></input>

<input type="radio" name="typeId{0}" value="2" onclick="changeAddItemButton({0},this.value)">

<@s.m "cmsVoteTopic.type.mul"/>

</input><input type="radio" name="typeId{0}" value="3" onclick="changeAddItemButton({0},this.value)">

<@s.m "cmsVoteTopic.type.text"/></input>
<input type="hidden" name="subTopicId" value=""/>
&nbsp;
 <input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="$(this).parent().remove();"/>
<span id="voteItemMsg{0}" style="color: red;"></span>
<span><@s.m "cmsVoteTopic.items"/>&nbsp; <input id="addItem{0}" type="button" class="add_item" value="<@s.m "cmsVoteItem.addLines"/>" onclick="addLines({0});"/></span>
<input type="hidden" name="itemTitle" value="<@s.m "cmsVoteItem.splitchar"/>"/>
<div id="itemsContainer{0}"></div>
<input type="hidden" name="itemTitle" value="<@s.m "cmsVoteItem.splitchar"/>"/>
</div>
</textarea>

<textarea id="itemTpl" style="display:none;">
<div class="items">
<@s.m "cmsVoteItem.title"/>: <input type="text" id="{0}_{1}" name="itemTitle" style="width:300px"/>
&nbsp; <@s.m "cmsVoteItem.voteCount"/>: <input type="text"  name="itemVoteCount" value="0" style="width:50px"/>
&nbsp; <@s.m "cmsVoteItem.priority"/>: <input type="text" name="itemPriority" value="{1}" style="width:30px"/>
&nbsp; <input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="$(this).parent().remove();"/>
</div>
</textarea>
<script type="text/javascript">
var tpl = $.format($("#itemTpl").val());
var index = ${cmsVoteTopic.items?size}+1;
function addLines(ind) {
$("#itemsContainer"+ind).append(tpl(ind,index++));
}
var subtpl = $.format($("#subTopicTpl").val());
var subindex = ${cmsVoteTopic.subtopics?size}+1;
function addSubTopic() {
$("#subTopicContainer").append(subtpl(subindex++));
}
1 共1页