【发布时间】:2016-12-07 17:21:43
【问题描述】:
我通过这个例子使用 selectize 和流星: meteor is not working with selectize.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>
所以在 onChange 事件上我想得到 p>
值和id
将该值保存到数据库中。
结果可能是这样的:{id: 1, text: google}
那我该怎么做呢?
来自流星的新手
【问题讨论】:
标签: javascript jquery meteor selectize.js