有没有一种简单的方法可以让 dojo/dijit 工具包与淘汰可观察量一起使用?
如果我有一个声明的选择
<select id="sel1" dojoType="dijit.form.Select" >...
并且我添加了我的淘汰数据绑定
<select id="sel1" dojoType="dijit.form.Select" data-bind=".....">...
如果淘汰数组/绑定在dojo.ready之前初始化,那么选择框会填充正确的值,但是因为dojo重写了模板,我们会丢失我们的可观察值。
我宁愿不迁移到 dojo observables,但在这种情况下似乎我必须这样做。
我正在继续调查,但看来我们需要采取这一行动。
If I have a declared select
<select id="sel1" dojoType="dijit.form.Select" >...
And I add my knockout data binding
<select id="sel1" dojoType="dijit.form.Select" data-bind=".....">...
If the knockout array/bind is initialised prior to the dojo.ready they the select box is populated with the correct values, however because dojo re-writes the templates we lose our observables.
I'd rather not migrate to dojo observables but this seems like I'd have to in this case.
I am continuing to investigate but it looks like we'll need to make this move.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:这不是答案,尽管它是一个起点。
看起来有淘汰道场连接器。
https://github.com/imankulov/knockout-dojo-connector /blob/master/sample.html
但没有 observablearrays 和与 select 绑定的示例。
Edit: This is not the answer, although it is a starting point.
It looks like there is knockout dojo connector.
https://github.com/imankulov/knockout-dojo-connector/blob/master/sample.html
But no samples for observablearrays and binding with selects.
我不太喜欢淘汰道场连接器的方法。我认为更简洁的方法是将 KO 绑定保留在标记中,并为您的 dojo 类型应用 attr 绑定。
像这样的东西应该有效:
I'm not a big fan of the approach by knockout-dojo-connector. I think a cleaner approach would be to keep your KO bindings in your markup and apply an attr binding for your dojo type.
Something like this should work:
<select id="sel1" data-bind="attr: {'dojoType': dojoTypeInViewModel}">...