MagicSuggest - set magic suggest list with pre sel

2019-06-27 04:36发布

I am using MagicSuggest to populate tag list from following JSON data:

{"Id":"money","name":"money"},{"Id":"education","name":"education"}]

while I am going to edit page, need to pre-populate the selected tags:- like one pre-populated tag: money

Please suggest how I can set magic suggest list with pre selected items

Below code is the one which I have tried so far :

var article_tags = $('#article_tags').magicSuggest({
    data: 'http://localhost:1043/Tag/TagData',
    sortOrder: 'name',
    valueField: 'name',
    minChars: 0,
    value: ['money'],
    maxResults: false,
    name: 'article_tags',
    allowFreeEntries: false,
    selectionPosition: 'right',
    //groupBy: 'name',
    maxDropHeight: 200
});

1条回答
女痞
2楼-- · 2019-06-27 05:27

Up to 1.3, the component restricted the developer to only select values amongst its current data set. The data is fetched asynchronously, meaning that the value is set prior to the data being fetched: hence the component couldn't find the value and would not set it.

This has now changed in the 2.0 release and your code should actually work just fine if you update your library.

查看更多
登录 后发表回答