KnockoutJS + Polymer:绑定中断(Chrome外) [英] KnockoutJS + Polymer: bindings break (Outside of Chrome)

查看:125
本文介绍了KnockoutJS + Polymer:绑定中断(Chrome外)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:这只显示在Chrome之外

This only appears outside of Chrome

我使用KO使用foreach绑定填充元素。在硬币的另一边,我有Polymer加载了使用Google的Material Design样式。

I'm using KO to fill in elements using foreach bindings. On the other side of the coin, I've got Polymer loaded up to make use of Google's Material Design styling.

问题是,似乎有一个断言即使Polymer不使用data-bind属性,尝试接管 data-bind 的platform.js文件(Polymer)。

The issue is that there seems to be an assertion in the platform.js file (Polymer) that is trying to take over the data-bind even though Polymer doesn't use the data-bind attribute.

想知道任何人是否有使用这两者的任何经验,或任何建议?错误如下:

Wondering if anybody has had any experience using both of these, or any suggestions? Error is below:

错误:无法处理绑定template:function(){return {foreach:sessions}}
消息:断言失败

JSFiddle: http://jsfiddle.net/Rmp6c/3/

JSFiddle: http://jsfiddle.net/Rmp6c/3/

编辑:所以我设置了调试版本,似乎在ShadowDOM /src/wrappers.js在第31行有一个 assert(b)函数被传递一个布尔值。这是一个Node.js文件称为100倍的时间,并修复这看起来像需要一个相当大的重写。

So I've setup the debug version, and it appears that inside ShadowDOM/src/wrappers.js on line 31 there is an assert(b) function that is being passed a boolean. This is called 100s of times by a Node.js file, and to fix this looks like it would require a fairly large rewrite.

我的解决方法是使用jQuery插入带有foreach绑定的DOM元素,然后将我的KO绑定应用到 $(document).ready(function(){}); 标签中。这似乎在所有浏览器上都有效。

My fix for this has been to use jQuery to insert the DOM element with the foreach binding, and then apply my KO bindings inside a $(document).ready(function() {}); tag. This appears to work on all browsers.

推荐答案

我的修复是使用jQuery插入DOM元素与foreach绑定,然后应用我的KO绑定在$(文档).ready(function(){});标签。这似乎在所有浏览器上都有效。

My fix for this has been to use jQuery to insert the DOM element with the foreach binding, and then apply my KO bindings inside a $(document).ready(function() {}); tag. This appears to work on all browsers.

虽然这不是一个很好的解决方法 - 它是唯一一个正常工作。我已经接触到了KnockoutJS的Steve Sanderson,并相信他正在调查它。我使用Knockout Custom组件来解决这个问题的原因是,Polymer组件根据Google的新设计规范提供了Material Design,而我正在构建的Web前端本质上与我公司的移动应用程序相关联,所以我想保持一个连贯的设计。

While this isn't a great fix - it is the only one that has worked properly. I've reached out to Steve Sanderson of KnockoutJS and believe he's looking into it. The reason that I went with this fix over just using Knockout Custom components, is that the Polymer components offer Material Design as per Google's new design specs, and the web front-end that I'm building is intrinsically tied to my company's mobile application, so I wanted to maintain a cohesive design.

这篇关于KnockoutJS + Polymer:绑定中断(Chrome外)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆