-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
从 data-api 构建实例时,element 的含义应该可配置 #26
Comments
具体用什么名字待定 |
两种方式
重点是 data-element-role 的命名。 |
决定为 |
我还是觉得 data-element-role 好 等价 new Xxx({
element: '#xxx',
elementRole: 'trigger'
}) elementRole 本身也可以像上面的方式使用,表明传入的 element 是当 trigger 用的 |
这样不好,我们是要把当前 DOM 作为 trigger 参数传入,而不是把 element 视为 trigger。 element 和 trigger 是同时存在的两个 DOM。 |
是否 data-role-in-widget ? 纠结 On Tue, Apr 2, 2013 at 9:47 PM, Haoliang Gao [email protected]:
王保平 / 玉伯(射雕) |
实现中遇到的一些问题 现在的实现autoRenderAll 会找到所有的
实例化时在
问题如果增加 解决方案一解析 data-api 都放到 autoRender 中,解析后作为 config 传入,而不在 initialize 中处理。
如果
但是这个修改是不兼容的,原来直接实例化的时候也可以读取 element 上的 data-api。
如上,实例化 popup 的时候如果没有传入 className 会读取 data-api 上的,如果有会取 config 的。 解决方案二这个方案保留原有的功能,再增加一个属性(_element)指定
在 我比较推荐方案一,实现比较清晰。既然是实例化的何必再使用 data-api 呢,我觉得这种使用方式可以去除。在现实场景中有没有这种用法,你们的建议是 @lianqin7 @lifesinger @shaoshuai0102 |
config 的来源有三个:
之前的逻辑是,三者是覆盖关系,优先级 3 > 2 > 1 我觉得还是原来的逻辑好呀。 data-widget-role,我的想法是 SubWidget.autoRender({
initialElement: element,
renderType: 'auto'
}) 然后 autoRender 方法里面,根据 initialElement 来判断究竟是 element 还是 trigger 等。 |
@lifesinger 就是赞同方案二咯,把 _element 换成 initialElement |
还有一个问题,目前 Widget.query 是通过 cid 找实例的,而 cid 是绑在 element 上的。如果 initElement 为 trigger,那 cid 是否应该绑在 trigger 上。 |
嗯,可以让 cid 就绑在 initElement 上。 On Mon, May 13, 2013 at 3:26 PM, Haoliang Gao [email protected]:
王保平 / 玉伯(射雕) |
整理到文档 |
目前 data-api 存放在什么元素上,该元素就会被当成 widget 的 element
但 data-api 不一定仅存放在 widget element 上,还有可能存放在其他角色上,比如 trigger
因此可以考虑扩展:
上面自动会构建:
目前
{{element-role}}
始终是 "element", 改成上面的方式后,就可以自定义了。并且 data-api 也就可以存放在 widget 的非 element 元素上。
The text was updated successfully, but these errors were encountered: