Jquery 自动形成对象的自定义字段数组
我有一个用户模式,用户可能有一个团队列表,如本部分所示:Jquery 自动形成对象的自定义字段数组,jquery,meteor,meteor-autoform,Jquery,Meteor,Meteor Autoform,我有一个用户模式,用户可能有一个团队列表,如本部分所示: "teams": { type: [Object], optional: true, autoform: { label: "Teams", 'label-type': 'stacked', afFieldInput: { type: "tokenInput" } } }, "teams.$.name": { type: String, optional: true,
"teams": {
type: [Object],
optional: true,
autoform: {
label: "Teams",
'label-type': 'stacked',
afFieldInput: {
type: "tokenInput"
}
}
},
"teams.$.name": {
type: String,
optional: true,
autoform: {
ommit: true
}
},
"teams.$.address": {
type: String,
optional: true,
autoform: {
ommit: true
}
},
我想使用我使用jQuery令牌输入创建的简单自定义字段:
AutoForm.afTeams("tokenInput", {
template: "afTokenInput",
valueOut: function () {
return $("#tokenInput").tokenInput('get');
}
});
Template.afTeams.rendered = function() {
token();
function token() {
$("#tokenInput").tokenInput('/api/teams/?q', {
onReady: function() {
console.log('Ready...');
},
preventDuplicates: true,
minChars: 3,
propertyToSearch: 'name'
});
}
}
模板:
<template name="afTokenInput">
<input id="tokenInput" class="token" type="text" />
</template>
我只想显示jQuery令牌输入forteams字段,然后在提交时返回一个对象数组
仅当模式中的团队类型为字符串时,才会呈现我的模板,但对于对象数组,它会呈现标准的afArrayField和afObjectField
有没有办法克服这个问题?致:
这可能有效:
afQuickField: {
type: "tokenInput"
}
并确保在“名称”和“地址”字段中使用“省略”而不是“ommit”我必须将类型放入autoform对象中:
"teams": {
type: [Object],
optional: true,
autoform: {
type: "tokenInput",
label: "Teams",
'label-type': 'stacked'
}
},
并将{{atts}}放在模板中的某个位置以触发valueOut:
<template name="afTokenInput">
<input type="hidden" {{atts}} />
<input id="tokenInput" class="token" type="text" />
</template>
将类型移动到autoform对象中后,它就起作用了。无论如何,谢谢你。