【发布时间】:2016-03-01 00:40:19
【问题描述】:
我正在使用流星构建一个显示股票信息的网络应用程序。我目前在客户端有一个输入文本。输入连接到 Markit on Demand 的 Lookup API。这是代码:
Template.LookupTemplate.onRendered(function() {
this.$("#Lookup")
.focus()
.autocomplete({
source: function(request,response) {
$.ajax({
url: "http://dev.markitondemand.com/api/v2/Lookup/jsonp",
dataType: "jsonp",
data: {
input: request.term
},
success: function(data) {
response( $.map(data, function(item) {
return {
label: item.Name + " (" +item.Exchange+ ")",
value: item.Symbol
}
}));
},
minLength: 0,
select: function(event,ui ) {
console.log(ui.item);
}
});
}
});
}); //Closing tag of LoookupTemplate.onRendered
如何捕捉客户的选择?当用户开始输入公司名称时,jquery 自动完成功能会启动并为客户提供可供选择的选项列表。一旦用户选择它并点击“输入”(提交),页面就会重新加载到
http://localhost:3000/Overview?stockname=AAPL
我如何捕获该输入(在本例中为 AAPL),然后将其传递给为该特定股票构建图表的另一个函数?
--Router.js
Router.configure({
// 这是默认布局/顶级模板 布局模板:'布局' });
Router.map(function() {
this.route('/', {
path: '/',
action: function() {
this.redirect('landingpage')
document.title = 'Cash'
}
});
// Route for the landing page when user is not logged in
this.route('landingpage', {
path: '/landingpage',
after: function() {
document.title = 'Cash'
}
});
// Route to our main app. Note that I use / path as I treat this as default behavior
this.route('/Overview', {
path: '/Overview',
after: function () {
document.title = 'Cash';
}
});
})
【问题讨论】:
-
加载到下一页时为什么不使用路由器读取参数?
-
我该怎么做?我正在使用铁:路由器
标签: javascript jquery api meteor