【发布时间】:2016-09-11 17:36:01
【问题描述】:
我正在制作一个流星网络应用程序,用户将在其中单击一个 html 按钮。单击此按钮后,用户需要被引导到另一个页面,其中包含由流星简单模式包生成的一些表单。简单模式中的第一个字段需要自动赋予字符串值“hello”,然后简单模式中的其余字段将由用户使用页面上的输入字段填写。我不确定的是如何将第一个值自动设置为此字符串值。这是我的一些代码:
简单的模式声明:
LobbySchema = new SimpleSchema({
game: {
type: String,
label: "Game"
},
console: {
type: String,
label: "Console"
},
players: {
type: Number,
label: "Players"
},
mic: {
type: Boolean,
label: "Mic"
},
note: {
type: String,
label: "Note"
},
gamertag: {
type: String,
label: "Gamertag"
},
createdAt: {
type: Date,
label: "Created At",
autoValue: function(){
return new Date()
},
autoform: {
type: "hidden"
}
}
});
当点击 html 按钮时,模式“game”中的第一个字段需要被赋予值“hello”。现在我可以通过 onclick 函数使用按钮将该值分配给 javascript 变量:
function getElementText(elementID){
var elementText = "hello";
}
按钮将调用 getElementText 函数并让 elementText 变量等于“hello”。现在我需要将简单模式中的第一个字段分配给这个变量值“hello”,然后使用它,以便用户现在可以使用输入字段填写模式的其余部分,并使用此代码自动生成到 html 中:
{{> quickForm collection="Lobby" id="insertLobbyForm" type="insert" class="newLobbyForm"}}
如果您不想提供答案(也许它碰巧比我想象的更复杂),那么我很高兴收到指向可能对我有帮助的网站的链接。如果我没有很好地解释上面的情况,我也非常愿意解释这个问题。
【问题讨论】:
标签: javascript html mongodb meteor schema