问题
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)
selectize.js is in client/lib
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