Comments (4)
参考 #5 ,因为暂时还没实现renderChildAction
来指定,所以现在的ER看来没有你所说的功能。
在完整设想的ER中,完成你的功能有几个方法:
-
使用
controller.renderChildAction(url, container);
进入一个Action,这个Action会把View渲染在指定的container
中 -
自己写一个Action子类,重写
render
,在render()
调用时,把自己的target
根据model
给的值改掉,代码:var View = require('er/View'); function MyView() {} MyView.prototype.render = function() { this.container = this.model.get('targetContainer'); View.prototype.render.apply(this, arguments); } require('er/util').inherits(MyView, View); // Action里 createModel = function() { var model = Action.prototype.createModel.apply(this, arguments); model.set('targetContainer', 'whatever'); return model; }
你提的问题确实是没有考虑周全的(不包含非子Action也有这样的需求),因此会再额外加一个入口:
在Action的实现中,重写
createView
方法,得到View实例后,把其中的container
赋值,此后Action就不会再覆盖container
属性,保留原值(现在是会覆盖的,我会去修改)。
不知这样的解决方式是否能满足你的要求,如果有其它没顾及到的,请继续说明
from er.
解决方法倒是蛮多的,但就像你说的Action.prototype.createModel.apply这样感觉总是怪怪的。不过现在还没到强制使用的地步,先等renderChildAction实现,大家或多或少都需要这个。我继续看其他功能。
from er.
在 80639d8 中加了一个功能,如果Action的createView
返回的View实例有container
字段,Action不会去覆盖他,允许用户在这里自定义容器。其它方面的办法可以继续讨论
from er.
没人讨论,这个方案已经执行,后续有其它需求再打开。
from er.
Related Issues (20)
- 子Action中a标签外跳到一个er path的需求 HOT 7
- [template]etpl2/3从Model中取值问题 HOT 2
- deferred中加入一个方法控制串行请求合适么? HOT 9
- controller#forward,mix options给actionContext会出问题 HOT 2
- 两层以上的ChildAction里发生global redirect的时候会报错 HOT 6
- 页面切换次数多了的时候,会出现hash跳转了但是view没渲染的情况 HOT 24
- 开放路径访问权限方法 HOT 1
- enteractionfail事件增加参数
- ER 不在npmjs.org 里? HOT 4
- ER的两点疑问 HOT 11
- er/controller forwardaction 并不能阻止后续load行为 HOT 1
- 老ER里refresh 为啥只刷新控件,而不重载render整个 tpl HOT 1
- locator中updateURL函数为啥还要比较一次getLocation() !== url HOT 1
- er在ie6,7,8里哪些功能不能用? HOT 2
- 有什么地方可以设置所有的action在complete的时候执行同一个方法么? HOT 2
- [email protected] 与 [email protected] 兼容问题 HOT 3
- Model 中复制 datasource 有 bug
- er的默认路径可以默认不显示吗?
- events.js中有几个event的说明重复有误
- 貌似这里promise resolver里this指向全局,并没有绑定当前context是promise
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from er.