From 70fd8f6118a3e8bf298dd9c48c310f3309b780c3 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Aleksander=20=C5=81ukasz?=
 <aleksander.lukasz@nowoczesnapolska.org.pl>
Date: Mon, 15 Apr 2013 16:43:56 +0200
Subject: [PATCH] Fixing event handling in visual editor

---
 modules/visualEditor.js | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/modules/visualEditor.js b/modules/visualEditor.js
index d8b30b7..08085de 100644
--- a/modules/visualEditor.js
+++ b/modules/visualEditor.js
@@ -3,6 +3,16 @@ rng.modules.visualEditor = function(sandbox) {
 
     var view = {
         node: $(sandbox.getTemplate('main')()),
+        setup: function() {
+            var node = this.node;
+            node.find('#rng-visualEditor-content').on('keyup', function() {
+                isDirty = true;
+            });
+            
+            node.find('#rng-visualEditor-meta').on('keyup', function() {
+                isDirty = true;
+            });
+        },
         getMetaData: function() {
             var toret = {};
             this.node.find('#rng-visualEditor-meta table tr').each(function() {
@@ -25,21 +35,14 @@ rng.modules.visualEditor = function(sandbox) {
             this.node.find('#rng-visualEditor-content').html(HTMLTree);
         },
         getBody: function() {
-            return this.find('#rng-visualEditor-content').html();
+            return this.node.find('#rng-visualEditor-content').html();
         }   
     };
+    view.setup();
     
     var isDirty = false;
     
     
-    $('#rng-visualEditor-content', view).on('keyup', function() {
-        isDirty = true;
-    });
-    
-    $('#rng-visualEditor-meta', view).on('keyup', function() {
-        isDirty = true;
-    });
-    
     return {
         start: function() {
             sandbox.publish('ready');
-- 
2.20.1