ajax加载后,selectize.js不会呈现选项

时间:2016-05-23 20:19:22

标签: ajax selectize.js

我正在尝试通过ajax将项目加载到selectize.js,但似乎无效。

Api工作正常,调用success方法但它不呈现任何项目,并且它不会输出render方法中给出的控制台。

这是它的样子(coffeescript)

FindUserDirective = ($http)->
  options =
    restrict: 'A'
    replace: false
    scope: true
    link: (scope, element, attrs)->
      $(element).selectize
        valueField: 'firstName'
        labelField: 'firstName'
        searchField: 'firstName'
        create: false
        render: option: (user, escape)->
          console.log user
          "<div>#{user.fullName}</div>"
        load: (query, callback)->
          if not query.length then callback()

          url = Routing.generate('api_cget_client', {uuid:config.studio.uuid})
          $http
            .get url
            .then(
              # on success
              (response)->
                callback response.data.users
                # this gives a beautiful array with users
              ,
              # on error
              (response)->
                callback()
            )
  options

application
  .directive('finduser' , FindUserDirective)

任何想法?

0 个答案:

没有答案