MagicSuggest - 使用预先选择的项目设置魔法建议列表 [英] MagicSuggest - set magic suggest list with pre selected items

查看:417
本文介绍了MagicSuggest - 使用预先选择的项目设置魔法建议列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 MagicSuggest
来填充以下JSON数据中的标记列表:

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

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

当我要编辑页面时,需要预先填充所选标签: -
类似于一个预先填充的标签: money

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.3,该组件仅限开发人员使用在当前数据集中选择值。数据是异步提取的,这意味着该值是在提取数据之前设置的:因此组件找不到该值,也不会设置它。

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.

这现在已经在2.0版本中进行了更改,如果您更新库,您的代码实际上应该可以正常工作。

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

这篇关于MagicSuggest - 使用预先选择的项目设置魔法建议列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆