0
這是我的路由頁如何在流星中提交表單?
Router.route('/search', function() {
// render the Home template with a custom data context
this.render('search', {data: {title: 'My Title'}});
});
的index.html
<head>
<title>Test</title>
</head>
<body>
</body>
search.html
<template name="search">
<form class="new-task">
<input type="text" name="text" placeholder="Type to add new tasks" />
<input type="submit" value="submit">
</form>
</template>
search.js
Template.body.events({
"submit .new-task": function (event) {
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
var text = event.target.text.value;
console.log(text)
// Insert a task into the collection
// event.target.text.value = "";
}
});
在這裏,我很老文本框的值到search.js,頁面再次重新編碼,url更改爲 http://192.168.1.33:3000/search?text=fgh當我提交表格
任何人都可以知道如何解決這個問題?
非常感謝你.... –