Changes between Initial Version and Version 1 of Ticket #13298
- Timestamp:
- May 17, 2020, 12:26:57 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #13298 – Description
initial v1 4 4 5 5 The problem is due to two changes: 6 * In r13452 the workflow controls were added to the new ticket page. We added the //create and assign// action .7 * In r13707 the `ticket_workflow` template was added and the associated !JavaScript was moved into this template. !The JavaScript disables workflow inputs associated with actions that are not selected . Since jQuery ready handlers executed in the order they are added, this JavaScript executes after autoSubmit initializes.6 * In r13452 the workflow controls were added to the new ticket page. We added the //create and assign// action, which includes a select box for assigning the owner. 7 * In r13707 the `ticket_workflow` template was added and the associated !JavaScript was moved into this template. !The JavaScript disables workflow inputs associated with actions that are not selected, such as the //create and assign// assign-to field. Since jQuery ready handlers executed in the order they are added, this JavaScript executes after autoSubmit initializes. 8 8 9 9 With the default workflow, `create` action will be selected when loading the New Ticket page. 10 10 11 [[Image( Screen Shot 2020-05-16 at 15.15.19.jpg)]]11 [[Image("Screen Shot 2020-05-16 at 15.15.19.jpg")]] 12 12 13 The `autoSubmit` will initialize and collect a list of all inputs which will includes the `#action_create_and_assign_reassign_owner` select. 13 The `autoSubmit` will initialize and collect a list of all inputs which will includes the `#action_create_and_assign_reassign_owner` select. After that happens, the `#action_create_and_assign_reassign_owner` select will be disabled. 14 14 15 15 [[Image("Screen Shot 2020-05-16 at 15.03.45.jpg")]] 16 16 17 Any of the events `input cut paste keydown keypress change blur` will trigger the callback, because the new array of form elements will be one-less than that which was originally stored.17 Any of the events `input cut paste keydown keypress change blur` will trigger the autopreview, because the new array of form elements will be one-less in length than that which was originally stored (the one-less is the absence of the `#action_create_and_assign_reassign_owner` element. 18 18 19 [[Image("Screen Shot 2020-05-16 at 15.06.43 ".jpg)]]19 [[Image("Screen Shot 2020-05-16 at 15.06.43.jpg")]] 20 20 21 21 I tried to solve this in several ways by executing the JavaScript in `ticket_workflow.html` immediately after the elements are created rather than adding a document ready handler. This results in a flicker in which the element is shown for milliseconds without being disabled. So I tried hiding the entire form element until the JavaScript is executed. It's a bit messy. … … 23 23 Or we could move the `script` block in `ticket.html` to the end of the page. 24 24 25 It looks like we can just initialize `values` on the first trigger, because we trigger on element losing focus `blur` as well as keydown, so`values` gets initialized before any elements of the form are changed.25 It looks like we can just initialize `values` on the first trigger, because we trigger on element losing focus (`blur`) as well as keydown, and `values` gets initialized before any elements of the form are changed. 26 26 {{{#!diff 27 27 diff --git a/trac/htdocs/js/auto_preview.js b/trac/htdocs/js/auto_preview.js