-
5 Jan 2012 5:29 PM #1
Ext.form.HtmlEditor breaks in IE9 after creating and destroying twice
Ext.form.HtmlEditor breaks in IE9 after creating and destroying twice
Original post here: http://www.sencha.com/forum/showthre...344#post708344
Ext version tested:- Ext 3.4.0
- ext
- ext-all.css with grey theme
- FF 8
- Chrome 16
- IE9
- IE8
- IE7
- Windows 7
- Mac OS 10.7
- I'm seeing an issue in IE9 (only) where destroying an Ext.form.HtmlEditor a twice is causing it to fail to initialize on all subsequent creations of the editor.
Load this example, and press the "Add/Replace Panel" button a few times.
Steps to reproduce the problem:HTML Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Test Html Editor IE9 Bug</title> <link rel="stylesheet" type="text/css" href="/js/ext/resources/css/ext-all.css"/> <link rel="stylesheet" type="text/css" href="/js/ext/resources/css/xtheme-gray.css"/> <script type="text/javascript" src="/js/ext/adapter/ext/ext-base-debug.js"></script> <script type="text/javascript" src="/js/ext/ext-all-debug-w-comments.js"></script> <script type="text/javascript"> Ext.onReady(function() { var w = new ExampleWindow(); w.show(); }); ExampleWindow = Ext.extend(Ext.Window, { panelCount: 1, initComponent: function() { Ext.apply(this, { height : 500, width : 700, layout: 'fit', items: { html: '<div>' + '<p>Editor will be rendered below</p>' + '<div id="comment-panel-wrap"></div>' + '<div id="my-output"></div>' + '</div>' }, buttons: [ { text: 'Add/Replace Panel', handler: this.addOrReplaceCommentPanel, scope: this } ] }); ExampleWindow.superclass.initComponent.call(this); }, addOrReplaceCommentPanel: function() { //if the reply comment panel appears elsewhere, get rid of it if(this.replyCommentPanel) { Ext.destroy(this.replyCommentPanel); delete this.replyCommentPanel; } this.replyCommentPanel = new Ext.Container({ cls: 'j-comment-panel j-reply-comment-panel', border: false, height: 189, items: [ this.createReplyCommentText() ], renderTo: 'comment-panel-wrap' }); //debug output Ext.getDom('my-output').innerHTML += '<br />Editor ' + this.panelCount + '... '; this.panelCount++; }, createReplyCommentText: function() { this.replyCommentText = new Ext.form.HtmlEditor({ height: 150, width: 250, hideLabel: true, enableAlignments: false, enableColors: false, enableFont: false, enableFontSize: false, enableSourceEdit: false, allowBlank: false, invalidText: 'You must enter a comment before you can submit', validateOnBlur: false, disabled: false, listeners: { initialize: this.onEditorInit } }); return this.replyCommentText; }, onEditorInit: function(component) { component.focus(false, 1000); //debug output Ext.getDom('my-output').innerHTML += ' initialized!'; } }); </script> </head> <body> </body> </html>
- In IE9, create and Ext.form.HtmlEditor twice in sequence
- Now create a third editor
- Never initializes (you can verify with an "initialized" event listener)
- "initialized" event would be fired upon initialization, like normal
- No initialization event is fired
- What I'm seeing happen is that there is an exception in the initEditor function in Ext.form.HtmlEditor. Specifically, this:
Code:Ext.EventManager.on(doc, { mousedown: fn, dblclick: fn, click: fn, keyup: fn, buffer:100 });
This call is throwing an exception "Permission Denied" (Error code is -2146828218), which is being swallowed in this function, and the editor never becomes initialized.
The confusing part about swallowing this exception is that everything still appears to work correctly, but when you call getValue(), you don't get anything since in syncValue(), it checks if the editor is initialized before copying the value into the hidden textarea.
A couple other details I've gathered:
- This issue doesn't appear in IE7 or IE8
- This issue also goes away in Quicks Mode
- This is most likely related to changing the design mode and still holding a reference to the old document (http://technet.microsoft.com/en-us/l...9(WS.10).aspx)... however, I didn't see this issue in Ext's source code
-
6 Jan 2012 9:28 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
This looks to be fixed in Ext JS 4. If you need a fix for you application, you will need to open a ticket at support.sencha.com
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
20 Jan 2012 2:28 PM #3
I discovered the fix for this issue for 3.x. Put this in an overrides file somewhere in your app:
Since the issue was fixed in Ext4, I did a diff between the two versions of the class until I could find out what was making one work and the other not.Code:Ext.form.HtmlEditor.prototype.initEditor = Ext.util.Functions.createSequence(
Ext.form.HtmlEditor.prototype.initEditor, function() {Ext.EventManager.on(window, 'unload', this.beforeDestroy, this);});
-
31 Oct 2012 7:17 PM #4
Thanks JavaSoftware-Sencha, you override saved me a heap of pain.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote