0

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.

4

2 回答 2

4

虽然您可以使用该函数非常轻松地呈现固定的 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
})
于 2013-08-23T18:55:03.407 回答
1

有几种方法可以做到这一点。

假设视图从 扩展SC.View,最简单的可能是覆盖#render方法并自己添加 iframe:

MyApp.MyView = SC.View.extend({
  render: function(context) {
    context.push("<iframe src='http://google.com' />");
  }
});
于 2013-08-23T16:04:45.160 回答