Opened 10 years ago
Last modified 6 months ago
#11719 new defect
Auto-preview breaks TicketExt plugin, possibily others — at Initial Version
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
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 Trac-Hacks.)