【问题标题】:Semantic UI Error on search搜索时出现语义 UI 错误
【发布时间】:2017-02-24 16:40:35
【问题描述】:

当我使用 jQuery 进行语义 UI 搜索时,我遇到了一些问题:

API:已使用 API 操作,但未定义 url 搜索对象 {}

API:没有为 api 事件指定 URL

我的代码:

 $('#product_name').keyup(function() {
      if($(this).val().length >= 2) 
      {
          $.getJSON('http://localhost/eval/www/validations/add/' + $(this).val() + '?do=findProducts', function(payload) {
              var content = payload.products;
              $('.ui.search').search({
                  source: content
              });
              console.log('Data: ',content);
          });
      }
  });

在内容 a 中有正确的数据,但出现此错误?你能帮帮我吗?

谢谢。

【问题讨论】:

    标签: jquery semantic-ui nette


    【解决方案1】:

    如果您正在使用语义 ui 并希望从服务器端获取数据,那么您应该像下面这样使用它。

    $('.ui.search')
      .search({
        minCharacters : 2,
        apiSettings: {
          url: 'https://api.github.com/search/repositories?q={query}'
        },
        fields: {
          results : 'items',
          title   : 'name',
          url     : 'html_url'
        }
      })
    ;
    

    如语义方面所述。您还可以使用控制最小键输入 minCharacters 如上例所示。当输入 2 个字符时,它将开始搜索。

    【讨论】:

    • 这个我知道,但是我的变量内容是json数组的类型
    • 上面的例子也在 json 数组中获取 res。你试过这种方法吗?
    猜你喜欢
    • 2013-06-26
    • 1970-01-01
    • 2016-10-01
    • 1970-01-01
    • 2020-10-14
    • 2012-01-28
    • 2018-08-08
    • 2012-10-03
    • 1970-01-01
    相关资源
    最近更新 更多