留言板

textboxlist pre-select items

Joshua Graham,修改在8 年前。

textboxlist pre-select items

New Member 帖子: 8 加入日期: 15-10-6 最近的帖子
Hi Guys,

I have a aui-texboxlist on one of my pages and I would like to set some of the items as pre-selected. What is the best way to do this?

I'm using the "dataSource" attribute to load a list of auto-complete items

I can add an item using the textboxlist.add("item text") however doing it this way break my "add" and "remove" handlers.


var textBoxList = new A.TextboxList(
{   dataSource: [["something", "like", "this"]],
    schema: ['key', 'listItem', 'name'],
    matchKey: 'name',
});
tboxList.add("this"); //this makes "this" appear in the textboxlist 
///but doesn't set the item.key element in the remove event
tBoxList.entries.after('remove', function(event) {
        event.item.key === undefined
        });
thumbnail
Nate Cavanaugh,修改在8 年前。

RE: textboxlist pre-select items

Junior Member 帖子: 94 加入日期: 06-11-27 最近的帖子
Hi Josh,
Unfortunately, when you call add with the value, it doesn't look up the data source reference internally, since there could technically be multiple entries for the same value.

However, the way I can imagine doing it would be to manually add it to the underlying entries object and change the add call to this:

tboxList.entries.add({
key: 'something',
listItem: 'like',
name: 'this'
});


Hope that helps a bit,