观察 Sproutcore 的私人财产
是否可以观察私有(下划线)属性 在对象本身内? 我需要知道 _view_layer 何时设置,以便我可以应用 一些 jQuery 甚至处理程序。不幸的是 init() 和 render() 是 真的很早,所以 _view_layer 未定义。 不幸的是,观察 _view_layer 似乎效果不佳。 请告诉我我能做什么。基本上,如果还有另一种可能 解决方案,我也愿意看到这一点
Is it possible to observe private (underscored ) properties from
within the object itself?
I need to know when _view_layer is getting set, so that I can apply
some jQuery even handlers. Unfortunately init() and render() are
really early, so _view_layer is undefined.
Unfortunately, observing _view_layer doesn't seem to work as well.
Please, tell me what I can do. Basically, if there is another possible
solution, I am open to see that as well
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Sproutcore 中,下划线只是属性/方法是私有的约定。它实际上不是私人的。
在 Sproutcore 中,视图具有生命周期方法。这可能会让人感兴趣(摘自 SC 1.4.5 代码):
SC 1.6 及更高版本中的视图发生了巨大变化,但我相信
didCreateLayer
仍然可以被识别。In Sproutcore the underscore is only a convention that the property/method is private. Its not actually private.
In Sproutcore, the views have life-cycle methods. This one might be of interest (taken from SC 1.4.5 code in view):
Views have changed drastically in SC 1.6 and later, but I believe that
didCreateLayer
is still recognized.需要 ES5 浏览器。
仅建议用于调试。您还可以使用
.watch
在 Firefox 中调试时。Requires an ES5 browser.
Only recommended to use for debugging. You can also use
.watch
when debugging in firefox.