Foros de discusión
textboxlist pre-select items
Joshua Graham, modificado hace 8 años.
textboxlist pre-select items
New Member Mensajes: 8 Fecha de incorporación: 6/10/15 Mensajes recientes
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.
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
});
Nate Cavanaugh, modificado hace 8 años.
RE: textboxlist pre-select items
Junior Member Mensajes: 94 Fecha de incorporación: 27/11/06 Mensajes recientes
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:
Hope that helps a bit,
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,