lundi 23 janvier 2017

Check for readyState in an Ember app

I have an iframe in my template as below;

<iframe id="iframeContainer" src="javascript:;"></iframe>

In the corresponding route, I want some form to be appended dynamically. I want it to work in IE, Firefox & Chrome. However the code inside readyState is not triggered at all. Not sure if I am not adding the check in the correct place ?

didTransition: function() {
    var self = this;
    Ember.run.scheduleOnce('afterRender', this, function() {
        document.addEventListener('readystatechange', function() {
            if (document.readyState == 'complete') {
                var iframeContainer = document.getElementById('iframeContainer');
                var innerDoc = (iframeContainer.contentDocument) ? iframeContainer.contentDocument : iframeContainer.contentWindow.document;
                innerDoc.body.innerHTML += '<form id="myForm"></form>';
                innerDoc.getElementById("myForm").submit();
            }
        });
    })
}




Aucun commentaire:

Enregistrer un commentaire