Modify ↓
Opened 13 years ago
Closed 11 years ago
#9596 closed defect (fixed)
dynamically adding textareas causes multiple toolbars for existing textareas
Reported by: | wasserman | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Component: | TracWysiwygPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description
I have a use case where new textarea form fields can be added dynamically via JavaScript. The current logic adds new TracWysiwyg instances with corresponding toolbars to all textareas via TracWysiwyg.initialize. When a new textarea is created this causes each existing textarea to get an additional toolbar. This can be avoided by creating a property in each textarea and associating it to its TracWysiwyg instance after it is created. Here is suggested patch:
-
tracwysiwyg/htdocs/wysiwyg.js
Index: tracwysiwyg/htdocs/wysiwyg.js
4005 4005 var textareas = document.getElementsByTagName("textarea"); 4006 4006 for (var i = 0; i < textareas.length; i++) { 4007 4007 var textarea = textareas[i]; 4008 if (/\bwikitext\b/.test(textarea.className || "")) { 4009 TracWysiwyg.newInstance(textarea, options); 4008 if (/\bwikitext\b/.test(textarea.className || "") 4009 && !textarea.wysiwyg) { 4010 textarea.wysiwyg = TracWysiwyg.newInstance(textarea, options); 4010 4011 } 4011 4012 } 4012 4013 };
Attachments (0)
Change History (2)
comment:1 Changed 13 years ago by
Summary: | dynamically adding textareas causes multiple toolbars to existing textareas → dynamically adding textareas causes multiple toolbars for existing textareas |
---|
comment:2 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
In 13453: