Commit 5ea3813b authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix inline examples in IE8.

Using Ext.Element#on to attach load event handler to iframe element.
Assigning handler directly to iframe.onload didn't work in IE8.

I'm sure it also fixes the same problem in IE7 (at least it does so in
IE7-mode of IE8), and the fix itself is just applying the right way of
doing things.
parent 8c31bae9
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -90,21 +90,21 @@ Ext.define('Docs.view.examples.InlinePreview', {
     */
    update: function(code) {
        var options = this.options;
        var iframe = document.getElementById(this.iframeId);
        var iframe = Ext.get(this.iframeId);
        var callback = Ext.Function.bind(this.iframeCallback, this);

        if (iframe) {
            // Something is not quite ready when onload fires.
            // I'm unsure what I should wait for. So I'm currently adding just this nasty delay.
            // 1 ms works in Chrome, Firefox wants something bigger. Works in IE too.
            iframe.onload = function() {
            iframe.on('load', function() {
                Ext.Function.defer(function() {
                    // Append newline to code, otherwise we might result in syntax error as
                    // eval() doesn't like when code ends with line-comment.
                    iframe.contentWindow.loadInlineExample(code+"\n", options, callback);
                    iframe.dom.contentWindow.loadInlineExample(code+"\n", options, callback);
                }, 100);
            };
            iframe.src = "eg-iframe.html";
            }, this, {single: true});
            iframe.dom.src = "eg-iframe.html";
        }
    },