: 당신의 auto-fields
에서
<aui:select id="elementIdPrefix0" name="elementIdPrefix0" label="Number" showEmptyOption='true' > <!-- options go here --></aui:select>
, 당신은 clone
이벤트에 대한 on
이벤트 리스너를 제공해야합니다. 콜백 내에서 방금 생성 된 행 컨테이너 노드 내에서 <aui:select>
을 조회합니다 (은 콜백에 매개 변수으로 전달됨).
<script>
AUI().use('liferay-auto-fields', 'aui-form-validator', function(A){
//Setup rules
var elementIdPrefix = '<portlet:namespace />elementIdPrefix',
myRules = {},
rulesRepository = {};
rulesRepository[elementIdPrefix] = {required:true};
myRules [elementIdPrefix + '0'] = rulesRepository[elementIdPrefix];
//Define validator
var validator = new A.FormValidator({
boundingBox: '#<portlet:namespace />myForm',
rules: myRules
});
new Liferay.AutoFields({
contentBox: '#my-fields',
fieldIndexes: '<portlet:namespace />indexes',
on: {
'clone': function(container){
//Lookup the clone
AUI().all('[name^=<portlet:namespace />elementId]').each(function(node, index){
if(container.row.contains(node)){
console.log("Assign to " + node.get('id'))
//inject the rules
myRules [node.get('id')] = rulesRepository[elementIdPrefix]
}
})
}
}
}).render();
});
</script>
이상적으로, 당신은 clone
컨테이너 내에서 노드를 얻기 위해 아이 선택기를 사용할 수 있어야합니다. 그 방법을 작동시키지 못했기 때문에 다른 방식으로 제공해야했습니다. 내 접근 방식을 사용할 수있는 이유는 내가 elementIdPrefix
이 무엇인지 알고 있기 때문입니다. 예를 제공 할 수 있기 위해 나는 앞서 가서이 사실을 이용했다.
더욱 역동적 인 접근 방식을 사용하려면 myNode.one('> selectorString');
과 같은 선택기를 사용해야합니다.
나는 또한 다음과 같이 질문했습니다. (http://www.liferay.com/community/forums/-message_boards/message/38630011?_19_redirect=http%3A%2F%2Fwww.liferay.com% 2Fcommunity % 2Fforums % 2F- % 2Fmessage_boards % 2Fsearch % 3F_19_keywords % 3Dautofields % 26_19_searchCategoryId % 3D0 % 26_19_BreadcrumbsCategoryId % 3D0 % 26_19_redirect % 3Dhttp % 253A % 252F % 252Fwww.liferay.com % 252Fcommunity % 252Fforums % 252F- % 252Fmessage_boards % 252Fmessage % 252F15088039 % 26_19_formDate % 3D1402068697228)에 대한 질문을 평생 포럼에 게시했습니다. – Origineil
필드가 양식의 일부입니까? – Origineil
예 Origineil, 필드는 양식 –