1+ Active: <g:if test =" ${ item? . active } " ><span id =" item-active-show" class =" label label-success" >ACTIVE</span ></g:if >
2+ <g:else ><span id =" item-active-show" class =" label label-danger" >INACTIVE</span ></g:else >
3+ <span id =" item-active-select" style =" display :none " >
4+ <select name =" active" >
5+ <option value =" true" >ACTIVE</option >
6+ <option value =" false" >INACTIVE</option >
7+ </select >
8+ <button id =" item-active-save" class =" btn btn-primary" >Save</button >
9+ <button id =" item-active-cancel" class =" btn btn-default" >Cancel</button >
10+ </span >
11+
12+ <script >
13+ $ (" #item-active-show" ).click (function (){
14+ $ (" #item-active-show" ).hide ();
15+ $ (" #item-active-select" ).show ();
16+ });
17+
18+ $ (" #item-active-save" ).click (function (){
19+ var active = $ (" #item-active-select option:selected" ).val ();
20+
21+ $ .ajax ({ url: " /pegr/item/updateActiveAjax?itemId=${ item. id } &active=" + active,
22+ success : function (result ) {
23+ if (result .active ) {
24+ $ (" #item-active-show" ).text (' ACTIVE' );
25+ } else {
26+ $ (" #item-active-show" ).text (' INACTIVE' );
27+ }
28+
29+ $ (" #item-active-show" ).removeClass ();
30+ $ (" #item-active-show" ).addClass (result .label );
31+ $ (" #item-active-select" ).val (result .active );
32+ $ (" #item-active-show" ).show ();
33+ $ (" #item-active-select" ).hide ();
34+ }
35+ });
36+ });
37+
38+ $ (" #item-active-cancel" ).click (function (){
39+ $ (" #item-active-show" ).show ();
40+ var active = $ (" #item-active-show" ).text ();
41+ $ (" #item-active-select" ).val (active);
42+ $ (" #item-active-select" ).hide ();
43+ });
44+ </script >
0 commit comments