MagicSuggest - set magic suggest list with pre selected items

我与影子孤独终老i 提交于 2019-12-10 17:17:47

问题


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:


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.



来源:https://stackoverflow.com/questions/21075706/magicsuggest-set-magic-suggest-list-with-pre-selected-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!