Created
May 4, 2011 18:14
-
-
Save nickh/955699 to your computer and use it in GitHub Desktop.
CKEditor + Backbone: play nicer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/public/javascripts/app/views/messages/message.js b/public/javascrip | |
index ae6e29f..f6f5534 100644 | |
--- a/public/javascripts/app/views/messages/message.js | |
+++ b/public/javascripts/app/views/messages/message.js | |
@@ -21,6 +21,10 @@ VR.Views.Messages.Components.Base = VR.Views.Base.extend({ | |
}, | |
validate: function( silent ) { | |
+ if ( this.beforeValidate ) { | |
+ this.beforeValidate(); | |
+ }; | |
+ | |
var view = this; | |
var $required_inputs = this.$j('.required input, .required textarea'); | |
var all_passed_validation = _( $required_inputs.map( function() { | |
@@ -218,6 +222,7 @@ VR.Views.Messages.Components.Editor = VR.Views.Messages.Comp | |
}; | |
var view = this; | |
+ | |
this.els.$html_editor_link.click( function( e ) { | |
e.preventDefault(); | |
view.els.$html_editor.show(); | |
@@ -246,6 +251,12 @@ VR.Views.Messages.Components.Editor = VR.Views.Messages.Com | |
this.els.$text_body_field.attr( 'disabled', this.model.get( 'text_auto_gene | |
}, | |
+ // See aforementioned CKEditor/event fail; ensure that content has been synce | |
+ // before trying to validate content. | |
+ beforeValidate: function(){ | |
+ this.syncHtmlBody(); | |
+ }, | |
+ | |
beforeSave: function(){ | |
this.syncHtmlBody(); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment