Commits

Rich Leland committed d3e2574

Tweaked widget render to fix duplicate on inlines. Fixes #4.

Comments (0)

Files changed (1)

markitup/widgets.py

             auto_preview = "$('a[title=\"Preview\"]').trigger('mouseup');"
         else: auto_preview = ''
 
-        html += ('<script type="text/javascript">'
-                '(function($) { '
-                 '$(document).ready(function() {'
-                 '  $("#%(id)s").markItUp(mySettings);'
-                 '  %(auto_preview)s '
-                 '});'
-                 '})(jQuery);'
-                 '</script>' % {'id': attrs['id'],
-                                'auto_preview': auto_preview })
+        html += """
+        <script type="text/javascript">
+        (function($) {
+          $(document).ready(function() {
+            var element = $("#%(id)s");
+            if(!element.hasClass("markItUpEditor")) {
+              element.markItUp(mySettings);
+            }
+            %(auto_preview)s
+          });
+          })(jQuery);
+        </script>'
+        """ % {'id': attrs['id'], 'auto_preview': auto_preview }
+
         return mark_safe(html)