简体   繁体   English

AUI文本框列表-检索已删除元素的值

[英]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 in event.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.

相关问题 如果任何aui表单字段值被更改,则启用aui按钮 - Enable aui button if any aui form fields value gets changed 在liferay中将动态元素添加到aui表单中 - Adding dynamic elements to aui form in liferay AUI复选框未显示为已选中,但值为true - AUI Checkbox not showing as checked but value is true 获取另一个文本字段(liferay aui)的文本字段的价值 - get value of a textfield onchage of another textfield (liferay aui ) 生成动态 div 并检索输入元素的值 - generate dynamic div and retrieve value of input elements 只应在向其添加元素时增加高度的 Div,如果删除项目,则保持先前增加的高度值 - Div that should only grow in height while elements are added to it, and keep the previoused increased height value if items are removed PHP-从数据库中检索值时,如果不为空,则启用元素 - php - enable elements if not empty when retrieve value from database 检索javascript中HTML元素的文字值,而不对&符号进行编码 - Retrieve literal value of HTML elements in javascript, without encoding ampersands 如何从servlet中的动态html表单元素中检索值 - how to retrieve value from dynamic html form elements in servlet Javascript / Vue JS - 检索 object 中所有元素的值 - Javascript / Vue JS - Retrieve value of all elements in object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM