[英]AUI textboxlist - retrieve removed elements value
I am using Liferay 6.2 and want to retrieve the value of removed element from a Textboxlist
component. 我正在使用Liferay 6.2,并希望从Textboxlist
组件中检索已删除元素的值。 I have stored a list of values in a hiddenInput
element, and I display the list in a Textboxlist
. 我已将值列表存储在hiddenInput
元素中,并将该列表显示在Textboxlist
。 As I remove the element, I want to update the values stores in the hidden input element. 删除元素时,我想更新隐藏输入元素中的值存储。 But I do not know how to retrieve the removed element. 但是我不知道如何检索删除的元素。
AUI().ready('aui-textboxlist-deprecated', function (A) {
var source = A.one('#hiddenInput').val().split(',');
var tagslist = new A.TextboxList({
contentBox: '#demo',
dataSource: source,
matchKey: 'name',
schema: {
resultFields: ['key', 'name']
},
schemaType: 'json',
typeAhead: true,
width: 500
}).render();
var values = A.one('#hiddenInput').val().split(',');
A.each(values, tagslist.add, tagslist);
var updateHiddenInput = function (event) {
//how to get the removed element?
}
tagslist.entries.after('remove', updateHiddenInput);
});
How to achieve this? 如何实现呢?
As @jbalsas said in the comments: 正如@jbalsas在评论中所说:
If you just need the label, then you can get it using
event.attrName
. 如果只需要标签,则可以使用event.attrName
获取它。 If you need to work with the element, it is passed inevent.item.entry
. 如果需要使用该元素,则在event.item.entry
传递它。
So you should be able to do it like this: 因此,您应该能够像这样:
var updateHiddenInput = function (event) {
var hiddenInput = A.one('#hiddenInput');
hiddenInput.val(hiddenInput.val() + ',' + event.item.entry); // or event.attrName
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.