Opened 10 years ago
Last modified 6 months ago
#11719 new defect
Auto-preview breaks TicketExt plugin, possibily others — at Version 3
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | high | Milestone: | next-major-releases |
Component: | ticket system | Version: | 1.0.1 |
Severity: | major | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
When auto-preview kicks in and new ticket content is returned via XHR, trac/ticket/templates/ticket.html
uses jQuery's .replaceWith()
function to update the page. This has the effect of dropping all the display: none
added to the page on initial load by TicketExt
.
One solution is to pass pass the XHR response through the same filters as the initial page load so the same manipulation (e.g., setting display attributes) can be applied.
Another is to change contents rather than replace the entire DOM subtree. This can be done with:
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.ht index 353ef63..d0865c3 100644
a b 79 79 $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) { 80 80 var items = $(reply); 81 81 // Update ticket box 82 $("#ticket").replaceWith(items.filter('#ticket')); 82 var newProps = $('table.properties td', items); 83 $('#ticket table.properties td').each(function(i) { 84 $(this).html(newProps.eq(i).html()); 85 }); 86 var newDescription = $('div.description div.searchable', items); 87 $('#ticket div.description div.searchable').html(newDescription.html()); 88 if (items.hasClass('ticketdraft')) 89 $('#ticket').addClass('ticketdraft'); 83 90 // Unthread, unrevert and update changelog 84 91 if (!$('#trac-comments-oldest').checked()) 85 92 $('#trac-comments-oldest').click().change();
though this is likely a partial fix.
(This has also been discussed at th:#11923.)
Change History (3)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Milestone: | → next-dev-1.1.x |
---|
comment:3 by , 10 years ago
Description: | modified (diff) |
---|---|
Milestone: | next-dev-1.1.x |
That patch has the following problems.
- When summary is changed, its value wouldn't be changed in preview.
- When status or type is changed, its value wouldn't be changed in preview.
- When field without value is set (or value is removed from field),
missing
class in its header wouldn't toggle in preview.
That would make auto-preview handler more complex. I like simple.
The issue is also seen with th:CondFieldsPlugin (th:#11920). I haven't tried to reproduce the issue with th:DynamicFieldsPlugin, but I wouldn't be surprised if it had the same issue.
I haven't dug deep into the issue, but a cursory look suggests that since the plugin's JavaScript has already been added to the page (
condfields.js
in the case of th:CondFieldsPlugin), we just need an event to fire after the DOM is updated by autopreview, which we could use to trigger the execution of the plugin's JavaScript.