各位大神,$("#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"/>
<@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=""/>
<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"/> <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"/>
<@s.m "cmsVoteItem.voteCount"/>: <input type="text" name="itemVoteCount" value="0" style="width:50px"/>
<@s.m "cmsVoteItem.priority"/>: <input type="text" name="itemPriority" value="{1}" style="width:30px"/>
<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++));
} |
|