我在ember.js中遇到以下问题.子控制器依赖于父控制器中的选定值来确定其内容.在数据库中,子项具有parent_id引用.
App.parentsController = Em.ArrayController.create({
content: [],
selected: null
});
App.sonsController = Em.ArrayController.create({
// the value of content depends on the id of
// the selected item in the parentsController
content: [],
selected: null
});
App.daughtersController = Em.ArrayController.create({
// the value of content depends on the id of
// the selected item in the parentsController
content: [],
selected: null
});
Run Code Online (Sandbox Code Playgroud)
我更愿意在没有parentController必须知道其他控制器的情况下解决这个问题.这应该可以通过观察者,绑定甚至通过计算实现,但我不知道从哪里开始.任何帮助将不胜感激.
我不知道这是否可能在python中,但这里...
我有一个类似于此的文件夹结构
\webapplication
\forms
__init__.py
model01.py # (defines Model01Form)
model02.py # (defines Model02Form)
\views
__init__.py
admin.py # (this file imports the forms)
Run Code Online (Sandbox Code Playgroud)
我想知道是否有任何方法可以像这样导入,但仍然将它们保存在单独的文件中.
from webapplication.forms import Model01Form, Model02Form
Run Code Online (Sandbox Code Playgroud)
而不是必须这样做
from webapplication.forms.model01.Model01Form
from webapplication.forms.model02.Model02Form
Run Code Online (Sandbox Code Playgroud)
提前致谢 :)
我的申请表上有以下Ember.Router:
App.Router = Ember.Router.extend({
location: 'hash',
rootElement: '#content',
enableLogging: true,
root: Ember.State.extend({
route: '/',
index: Ember.State.extend({
route: '/',
redirectsTo: 'main.welcome'
}),
main: Ember.State.extend({
route: '/main',
welcome: Ember.ViewState.extend({
route: '/welcome',
view: App.WelcomeView
})
})
})
});
Run Code Online (Sandbox Code Playgroud)
我希望能够做的是通过在声明它之后添加到App.Router来添加其他路由(这是为了启用任意模块).无论是在App.initialize()之前还是之后完成都不重要.
以下是模块路由对象的示例:
Module.routes = Ember.State.extend({
route: '/module',
index: Ember.State.extend({
route: '/'
view: Module.IndexView
})
});
Run Code Online (Sandbox Code Playgroud)
对此事的任何帮助都非常感谢.