Fix for CodeEditor's form submit handler; unbind the handler when we disable the editor, and rebind it when we enabled it. Prevents sometimes failing to copy in updates properly or failing during save because an obj is unavailable.

This commit is contained in:
Brion Vibber 2011-06-17 20:56:34 +00:00
parent 83dce47168
commit 852e1ee551
Notes: Brion Vibber 2011-06-17 20:56:34 +00:00

View file

@ -59,6 +59,9 @@ context.evt = $.extend( context.evt, {
'paste': function( event ) {
},
'ready': function( event ) {
},
'codeEditorSubmit': function( event ) {
context.$textarea.val( context.$textarea.textSelection( 'getContents' ) );
}
} );
@ -167,9 +170,7 @@ context.fn = $.extend( context.fn, {
}
}
];
box.closest('form').submit(function(event) {
box.val(context.fn.getContents());
});
box.closest('form').submit( context.evt.codeEditorSubmit );
context.codeEditor.getSession().setMode(new (require("ace/mode/" + lang).Mode));
// Force the box to resize horizontally to match in future :D
@ -201,6 +202,7 @@ context.fn = $.extend( context.fn, {
*/
'disableCodeEditor': function() {
// Kills it!
context.$textarea.closest('form').unbind('submit', context.evt.onCodeEditorSubmit );
// Save contents
context.$textarea.val(context.fn.getContents());