Project

General

Profile

applying custom jQuery after form is dynamically refreshed?

Added by Jeremy Merritt over 10 years ago

We are using a custom theme.js file with jQuery to make minor HTML modifications to issue forms (adding help links within labels, hiding unnecessary standard fields, adding additional text below certain dropdown boxes, etc). This jQuery function is called at $(document).ready.

Generally this is working fantastic, but has one major problem. When the Tracker or Status field is changed, the form is dynamically refreshed and all of the custom items added via jQuery is therefore lost.

The Tracker and Status fields have an onchange event that calls the Javascript function "updateIssueFrom". We have tried calling appending our custom jQuery function to this onchange event in hopes that it would be fired after updateIssueFrom was complete - and it is - but none of the custom jQuery items are added to the form. We've also tried adding a delay to our custom function, but no luck.

We're not Ruby programmers so we don't really understand what is happening behind the scenes of the updateIssueFrom function. Does anyone have any suggestions for ensuring that our custom jQuery can be applied after updateIssueFrom is completed and the form has been reloaded? Or is it just not possible?

Environment:
  Redmine version                2.4.1.stable
  Ruby version                   1.9.3-p0 (2011-10-30) [x86_64-linux]
  Rails version                  3.2.15
  Environment                    production
  Database adapter               Mysql2
SCM:
  Git                            1.7.9.5
  Filesystem                     
Redmine plugins:
  redmine_custom_css             0.1.2
  redmine_multi_column_custom_fields 0.0.1
  redmine_newissuealerts         0.0.2

Replies (1)

RE: applying custom jQuery after form is dynamically refreshed? - Added by Jeremy Merritt over 10 years ago

I think we were able to resolve this rather simply using the ajaxComplete function!

$(document).ajaxComplete(function(){
modifyIssue();
});

    (1-1/1)