$("#addPreparationProcessList").on("click", function () {
var index = $("#preparationProcessList").find("textarea").length;
var elementToAdd = '<div class="row"><div class="col-lg-8"><div class="input-group input-group-lg"><span class="input-group-addon" th:placeholder="#{placeholder.whatiscooking_placeholder}"></span>' +
'<textarea type="text" style="height:80px;" id="preparationProcessList' + index + '.preparationProcess" class="form-control top_margin_small"
th:placeholder="#{placeholder.whatiscooking_placeholder}"
placeholder="What is Cooking"></textarea> </div> </div>';
$("#preparationProcessList").append(elementToAdd);
});
这是我们在ui页面中调用此JQuery函数的示例代码,因此文本区域将添加到html页面。
此处:属性未解析为标签或占位符。
答案 0 :(得分:0)
为了让占位符得到解决,您需要将代码更改为:
<script th:inline="javascript">
//whatever else you have
$("#addPreparationProcessList").on("click", function () {
var whatIsCookingPlaceholder = /*[[#{placeholder.whatiscooking_placeholder}]]*/ 'test';
var index = $("#preparationProcessList").find("textarea").length;
var elementToAdd = '<div class="row"><div class="col-lg-8"><div class="input-group input-group-lg"><span class="input-group-addon" placeholder="' + whatIsCookingPlaceholder + '"></span>' +
'<textarea type="text" style="height:80px;" id="preparationProcessList' + index + '.preparationProcess" class="form-control top_margin_small"' +
'placeholder="' + whatIsCookingPlaceholder + '"></textarea> </div> </div>';
$("#preparationProcessList").append(elementToAdd);
});
</script>
查看文档的this部分以获取更多信息