I've got some legacy code to work with and I have no experience with Sprout Core. Searching for the answer has proven inconclusive.
Basically, I need to just an add an iframe to an already existing view, and be able to set the src URL.
I've got some legacy code to work with and I have no experience with Sprout Core. Searching for the answer has proven inconclusive.
Basically, I need to just an add an iframe to an already existing view, and be able to set the src URL.
虽然您可以使用该函数非常轻松地呈现固定的 iframe render
,但还有一个 SproutCore 视图,SC.WebView
可以在:desktop
框架中为您完成此操作。SC.WebView
如果您希望src
改变或者如果您想要调整 iframe 的大小以匹配其内容的大小,您应该使用。
例如,
myWebView: SC.WebView.extend({
layout: { left: 10, right: 10, top: 10, bottom: 10, border: 1 },
shouldAutoResize: true, // when the iframe loads, resize it to fit the size of its content
valueBinding: SC.Binding.oneWay('MyApp.currentUrl') // bind the 'src' of the iframe
})
有几种方法可以做到这一点。
假设视图从 扩展SC.View
,最简单的可能是覆盖#render方法并自己添加 iframe:
MyApp.MyView = SC.View.extend({
render: function(context) {
context.push("<iframe src='http://google.com' />");
}
});