iframe 内の html ドキュメントのビューを作成したいと考えています。次のような場合:
<div id="some">
<iframe id="other" />
</div>
サーバーから受け取った html ドキュメントをこの iframe に動的にロードしたいと考えています。問題は、そのドキュメントに Backbone View を使用したいということです。私がこのようなことをすると:
var projectView = Backbone.View.extend(
{
tagName: 'html',
initialize: function()
{
this.model.bind('sync', this.render, this);
},
render: function()
{
this.$el.html(this.model.get('content')); // content is from model, and it
//receives the html document from server
return this;
}
});
次に、私がするとき:
var iframe = $('#other')[0].contentWindow.document;
iframeDocument.open();
iframeDocument.write(projectView.render().el);
iframeDocument.close();
それは動作しません。さまざまな組み合わせを試しましたが、成功しませんでした。静的 html で document.write() を使用すると正常に動作しますが、バックボーン ビューと動的コンテンツをどのように処理すればよいですか?