0

I am using Liferay 6.2 and want to retrieve the value of removed element from a Textboxlist component. I have stored a list of values in a hiddenInput element, and I display the list in a 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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
user596502
  • 417
  • 3
  • 10
  • 22
  • 1
    If you just need the label, then you can get it using `event.attrName`. If you need to work with the element, it is passed in `event.item.entry`. – jbalsas Jul 18 '14 at 07:11

1 Answers1

0

As @jbalsas said in the comments:

If you just need the label, then you can get it using event.attrName. If you need to work with the element, it is passed in 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
}
Community
  • 1
  • 1
stiemannkj1
  • 4,418
  • 3
  • 25
  • 45