[793] | 1 | <script type="text/javascript"> |
---|
| 2 | var docRef_childCount = ${taskProcedureInstance?.documentReferences.size()} + 0; |
---|
| 3 | var docRef_wrapperId = "docRef_wrapper"; |
---|
| 4 | var docRef_cloneId = "documentReferenceLazyList_clone"; |
---|
| 5 | var docRef_lazyList = "documentReferenceLazyList"; |
---|
| 6 | var docRef_fields = ["toBeDeleted", "isNew", "name", "location"]; |
---|
| 7 | var docRef_focusField = "name"; |
---|
| 8 | |
---|
| 9 | // Click event on add button. |
---|
| 10 | jQuery('.add-docRef').live('click', function() { |
---|
| 11 | addChild(docRef_wrapperId, docRef_cloneId, docRef_lazyList, docRef_fields, docRef_focusField, docRef_childCount); |
---|
| 12 | docRef_childCount++; |
---|
| 13 | }); |
---|
| 14 | |
---|
| 15 | // Click event on delete buttons. |
---|
| 16 | jQuery('.del-docRef').live('click', function() { |
---|
| 17 | //find the parent div |
---|
| 18 | var prnt = jQuery(this).parents(".docRef-div"); |
---|
| 19 | //find the deleted hidden input |
---|
| 20 | var delInput = prnt.find("input[id$=toBeDeleted]"); |
---|
| 21 | //check if this is still not persisted |
---|
| 22 | var newValue = prnt.find("input[id$=isNew]").attr('value'); |
---|
| 23 | //if it is new then i can safely remove from dom |
---|
| 24 | if(newValue == 'true'){ |
---|
| 25 | prnt.remove(); |
---|
| 26 | }else{ |
---|
| 27 | //set the deletedFlag to true |
---|
| 28 | delInput.attr('value','true'); |
---|
| 29 | //hide the div |
---|
| 30 | prnt.hide(); |
---|
| 31 | } |
---|
| 32 | }); |
---|
| 33 | |
---|
| 34 | </script> |
---|
| 35 | |
---|
| 36 | <div> |
---|
| 37 | <table> |
---|
| 38 | <thead> |
---|
| 39 | <tr> |
---|
| 40 | |
---|
[806] | 41 | <th>Document Reference Name</th> |
---|
[793] | 42 | <th>Location</th> |
---|
| 43 | <th></th> |
---|
| 44 | |
---|
| 45 | </tr> |
---|
| 46 | </thead> |
---|
| 47 | <tbody id="docRef_wrapper"> |
---|
| 48 | <g:each var="docRef" in="${taskProcedureInstance.documentReferences}" status="i"> |
---|
| 49 | <g:render template="documentReference" model="['docRef': docRef, |
---|
| 50 | 'i':i]" /> |
---|
| 51 | </g:each> |
---|
| 52 | </tbody> |
---|
| 53 | </table> |
---|
| 54 | </div> |
---|
| 55 | |
---|
| 56 | <br /> |
---|
| 57 | |
---|
| 58 | <div style="text-align:right;"> |
---|
| 59 | <span class="buttons add-docRef"> |
---|
| 60 | <input type="button" class="add" value="Add Document Ref" /> |
---|
| 61 | </span> |
---|
| 62 | </div> |
---|