- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个相当简单的 Ember.js 应用程序。在一个 View 中,我调用 this.transitionTo 这给了我错误:
未捕获的类型错误:无法读取未定义的属性“输入”
错误位于 ember.js 的第 24596 行,其中 currentState 未定义
以下是我的应用程序的相关部分:
window.Plan = Ember.Application.create({});
Plan.Router = Ember.Router.extend({
location: 'hash'
});
Plan.IndexController = Ember.ObjectController.extend({
});
Plan.Router.map(function() {
this.route('application', { path: '/' })
this.route('index', { path: "/:current_savings/:monthly_deposit/:time_horizon" });
});
Plan.ApplicationRoute = Ember.Route.extend({
redirect: function(){
this.transitionTo('index', 200, 200, 200);
}
})
Plan.IndexRoute = Ember.Route.extend({
model: function(params) {
var result = this.store.find('calculation', params).then(function(data) {
return data.content[0];
});
return result;
}
});
Plan.CurrentSavingsTextField = Ember.TextField.extend({
focusOut: function() {
this.transitionTo('index', 150, 200, 200);
}
});
Plan.MonthlyContributionTextField = Ember.TextField.extend({
focusOut: function() {
this.transitionTo('index', 150, 200, 200);
}
});
Plan.TimeHorizonTextField = Ember.TextField.extend({
focusOut: function() {
this.transitionTo('index', 150, 200, 200);
}
});
Plan.Calculation = DS.Model.extend({
target_goal: DS.attr('number'),
target_return: DS.attr('number'),
expected_return: DS.attr('number'),
downside_probability: DS.attr('number')
});
Plan.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'plan/' + window.targetReturnId
});
<script type="text/x-handlebars" data-template-name="index">
<div>
<div>Starting Balance: {{view Plan.CurrentSavingsTextField size="10"}}</div>
<div>Monthly Contribution: {{view Plan.MonthlyContributionTextField size="10"}}</div>
<div>Time Horizon: {{view Plan.TimeHorizonTextField size="10"}}</div>
</div>
<div>
<span>Plan Goal: {{target_goal}}</span>
<span>Required Return: {{target_return}}</span>
<span>Exp Return: {{expected_return}}</span>
<span>Downside Probability: {{downside_probability}}</span>
<span>Time Horizon: {{time_horizon}}</span>
</div>
</script>
{
"calculations":[
{
"id":10,
"target_goal":3107800.0,
"target_return":0.089,
"expected_return":0.0708,
"downside_probability":0.0489
}
]
}
最佳答案
过去的kingpin2k是完全错误的,我从观点上错过了关于过渡的陈述。我道歉。transitionTo
不支持来自组件的(至少从我能找到的任何文档中)
您需要从组件中发送一个 Action 并在您的 Controller 或路由中捕获它。
Plan.CurrentSavingsTextField = Ember.TextField.extend({
focusOut: function() {
this.sendAction('go', 199, 200, 201);
}
});
Plan.IndexRoute = Ember.Route.extend({
model: function(params) {
var result = this.store.find('calculation', params);
//if you just wanted the first object
// result.then(function(collection){
// return collection.get('firstObject');
// });
return result;
},
actions:{
go: function(a, b, c){
console.log('transition');
this.transitionTo('index',a,b,c);
}
}
});
关于Ember.js:未捕获的类型错误:无法读取 transitionTo 上未定义的属性 'enter',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24421147/
我在使用 embers transitionTo 时遇到了一些问题,我无法让它将参数传递给上下文中的状态。尝试使用 test: Ember.Route.transitionTo('step', {st
我的 ember 应用程序包含一个带有两个嵌套路由的父路由。获取父路由的模型后,我将默认转换到其中一个嵌套路由。 路由器如下 this.resource('parent', {path: '/pare
import React from 'react'; import { Router, Link, Navigation } from 'react-router'; export default c
正如标题所暗示的那样,我正在尝试 transitionTo 一个 Action 的子路径。问题是 Ember 说它找不到任何具有该名称的路径。查看 Ember 文档,我不知道我在这里做错了什么。我希望
我有以下代码,当输入搜索查询并按下输入按钮或单击提交按钮时调用 transitionToRoute('search')。 但是,我的路由器仍然不会在模板中显示搜索查询: You searched fo
Ember 记录了一条警告,指出 transitionTo 已被弃用,取而代之的是 transitionToRoute。不过ember目前有route.transitionTo和controller.
我有一个调用 ember 组件来显示所有数据的 ember 路由。 我有一个案例,其中路由的键发生变化,我使用 route.transitionTo 重新加载。数据加载正常。但问题是组件在 init
我正在尝试使用具有可变参数的路由,这样我就可以使用参数来检查要解析到哪个状态。我做了一个简化的 plunker,它演示了我正在尝试做的事情。问题是目标路线的 Controller 似乎没有启动。然而,
我将 Ember.js 与 Phonegap 相结合,在这里您可以看到 Confirm API。但问题是我无法从这个事件驱动函数 onConfirm.. 执行 this.transitionTo('i
是否可以通过 Controller Action 触发加载路径? 例如: App.PostsController = Ember.ArrayController.extend( actions:
在我的 Angular Controller 中,我有部分代码 $state.transitionTo('newState', {}, { notify: false }) .then(funct
我正在使用 KineticJS 来旋转轮子,使其落在特定的点上。似乎发生在 iOS 上,每 1 秒转换一次。有没有办法提高渲染的性能? var dir = 1; if(direction == "le
Java Flight Recorder API 包含两个注释 TransitionFrom和 TransitionTo但文档对如何使用它们非常简单。 它们应该如何使用?我假设他们继续参加 Activ
我刚刚将我的应用程序升级到 ember 2.1 并在我的网络浏览器控制台中收到此错误: Uncaught TypeError: this.transitionTo is not a function
我有一个基本的搜索结果页面。这是我的用户界面路由器配置: $stateProvider .state('search', { url: '/search
我正在使用 Ember 1.9.1 并且在转换到带有查询参数的路由时遇到问题。 queryParams不要出现在网址中。 我收到了 http://localhost:8080/login 而不是 ht
在 Controller 中,我有一个使用 $state.transitionTo 的函数“重定向”到另一个状态。 现在我一直在测试这个功能,我总是收到错误 Error: No such state
我不知道如何在组件中的 re-base post 回调内部进行重定向。 https://github.com/tylermcginnis/re-base#postendpoint-options 我正
我有一个看起来像这样的链接 index.html#/calendar/year/month 这就是我设置路线的方式: App.Router.map(function() { this.reso
App.Router.map(function() { this.resource('documents', { path: '/documents' }, function() {
我是一名优秀的程序员,十分优秀!