How to get selectize.js to work with meteor.js

醉酒当歌 提交于 2019-12-08 07:29:01

问题


I am trying to implement a tagging system UI like the one seen on meteor forums (with dropdown menu of tags, colored squares, and descriptions.)

After some googling, I have come to the conclusion that selectize.js (https://brianreavis.github.io/selectize.js/) is one of the richest and most actively managed libraries for accomplishing tagging. My current install of selectize.js: (note: I already tried installing jeremy:selectize meteor package but didn't work either)

  1. selectize.js is in client/lib

  2. all stylesheets and other helper js files are in client/

However I can't get the following simple example to work https://www.github.com/brianreavis/selectize.js/blob/master/examples/customization.html in a meteor project.

When I click the select box, no dropdown of options appears, they are not even generated. :/ All I get is this:

----------HERE is my implementation in a meteor project----------

//js
Template.hello.onRendered(function(){
    $('#select-links').selectize({
      maxItems: null,
      valueField: 'id',
      searchField: 'title',
      options: [
        {id: 1, title: 'DIY', url: 'https://diy.org'},
        {id: 2, title: 'Google', url: 'http://google.com'},
        {id: 3, title: 'Yahoo', url: 'http://yahoo.com'},
      ],
      render: {
        option: function(data, escape) {
          return '<div class="option">' +
              '<span class="title">' + escape(data.title) + '</span>' +
              '<span class="url">' + escape(data.url) + '</span>' +
            '</div>';
        },
        item: function(data, escape) {
          return '<div class="item"><a href="' + escape(data.url) + '">' + escape(data.title) + '</a></div>';
        }
      },
      create: function(input) {
        return {
          id: 0,
          title: input,
          url: '#'
        };
      }
    });

});
<!-- html -->
<template name="hello">
<select id="select-links" placeholder="Pick some links..."></select>
</template>

Any help is greatly appreciated! If you give me a good answer, I will mark it as so.

Thanks - your fellow meteorite - Alex

来源:https://stackoverflow.com/questions/33621106/how-to-get-selectize-js-to-work-with-meteor-js

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