File tree Expand file tree Collapse file tree 6 files changed +34
-12
lines changed Expand file tree Collapse file tree 6 files changed +34
-12
lines changed Original file line number Diff line number Diff line change 11<span class =" input-group-btn" >
22 <button
3- href =" {{ $field [ ' on_the_fly ' ][ ' create_view ' ] ?? backpack_url ( $field [ ' on_the_fly ' ][ ' entity ' ]) . ' /ajax/create?field_name= ' . $field [ ' name ' ] . ' &attribute= ' . ( $field [ ' on_the_fly ' ][ ' attribute ' ] ?? ' name ' ) } } "
3+ href =" # "
44 type =" button"
55 class =" btn btn-primary"
66 style =" border-radius : 0px "
77 data-toggle =" modal"
8- data-target =" #{{ $field [' on_the_fly' ][' entity' ] ?? ' ajax_entity' } } _create_modal" >
8+ data-target =" #{{ $field [' on_the_fly' ][' entity' ] ?? ' ajax_entity' } } _create_modal"
9+ data-load-url =" {{ $field [' on_the_fly' ][' create_view' ] ?? backpack_url ($field [' on_the_fly' ][' entity' ]). ' /ajax/create?field_name=' . $field [' name' ]. ' &attribute=' . ($field [' on_the_fly' ][' attribute' ] ?? ' name' ) } }" >
910 <i class =" fa fa-plus" ></i >
1011 </button >
1112</span >
Original file line number Diff line number Diff line change 11<span class =" input-group-btn" >
22 <button
3- href =" {{ $field [ ' on_the_fly ' ][ ' edit_view ' ] ?? backpack_url ( $field [ ' on_the_fly ' ][ ' entity ' ]) . ' /ajax/edit?field_name= ' . $field [ ' name ' ] . ' &attribute= ' . ( $field [ ' on_the_fly ' ][ ' attribute ' ] ?? ' name ' ) } } &id=1 "
3+ href =" # "
44 type =" button"
55 class =" btn btn-warning"
66 style =" border-radius : 0px "
77 data-toggle =" modal"
8+ data-id =" {{ $field [' value' ] ?? ' ' } }"
89 data-target =" #{{ $field [' on_the_fly' ][' entity' ] ?? ' ajax_entity' } } _edit_modal"
9- onclick = " " >
10+ data-load-url = " {{ $field [ ' on_the_fly ' ][ ' edit_view ' ] ?? backpack_url ( $field [ ' on_the_fly ' ][ ' entity ' ]) . ' /ajax/edit?field_name= ' . $field [ ' name ' ] . ' &attribute= ' . ( $field [ ' on_the_fly ' ][ ' attribute ' ] ?? ' name ' ) } } " >
1011 <i class =" fa fa-pencil" ></i >
1112 </button >
1213</span >
Original file line number Diff line number Diff line change @@ -89,6 +89,26 @@ class="form-control"
8989@push (' crud_fields_scripts' )
9090 <script >
9191 jQuery (document ).ready (function ($ ) {
92+
93+ // load create modal content
94+ $ (" #{{ $field [' on_the_fly' ][' entity' ] ?? ' ajax_entity' } } _create_modal" ).on (' show.bs.modal' , function (e ) {
95+ var loadurl = $ (e .relatedTarget ).data (' load-url' );
96+ $ (this ).find (' .modal-content' ).load (loadurl);
97+ });
98+
99+ // load edit modal content
100+ $ (" #{{ $field [' on_the_fly' ][' entity' ] ?? ' ajax_entity' } } _edit_modal" ).on (' show.bs.modal' , function (e ) {
101+ var loadurl = $ (e .relatedTarget ).data (' load-url' );
102+ var id = $ (e .relatedTarget ).data (' id' );
103+ $ (this ).find (' .modal-content' ).load (loadurl + ' &id=' + id);
104+ });
105+
106+ // update id for edit modal url
107+ $ (" #select2_ajax_{{ $field [' name' ] } }" ).change (function (e ) {
108+ $ (" [data-target='#{{ $field [' on_the_fly' ][' entity' ] ?? ' ajax_entity' } } _edit_modal']" )
109+ .data (" id" , $ (" #select2_ajax_{{ $field [' name' ] } }" ).select2 (' data' )[0 ].id );
110+ })
111+
92112 // trigger select2 for each untriggered select2 box
93113 $ (" #select2_ajax_{{ $field [' name' ] } }" ).each (function (i , obj ) {
94114 var form = $ (obj).closest (' form' );
Original file line number Diff line number Diff line change 6969@push (' crud_fields_scripts' )
7070 <script >
7171 jQuery (document ).ready (function ($ ) {
72+ // load create modal content
73+ $ (" #{{ $field [' on_the_fly' ][' entity' ] ?? ' ajax_entity' } } _create_modal" ).on (' show.bs.modal' , function (e ) {
74+ var loadurl = $ (e .relatedTarget ).data (' load-url' );
75+ $ (this ).find (' .modal-content' ).load (loadurl);
76+ });
77+
7278 // trigger select2 for each untriggered select2 box
7379 $ (" #select2_ajax_multiple_{{ $field [' name' ] } }" ).each (function (i , obj ) {
7480 var form = $ (obj).closest (' form' );
Original file line number Diff line number Diff line change 3939 text: " {{ trans (' backpack::crud.insert_success' ) } }"
4040 });
4141
42- $ (" #{{ $entity } } _create_modal" ).modal (' toggle ' );
42+ $ (" #{{ $entity } } _create_modal" ).modal (' hide ' );
4343
4444 // provide auto-fill
4545
6262 setTimeout (function () {
6363 $ (' .select2-results__option' ).trigger (" mouseup" );
6464 }, 200 );
65-
66- console .log (data)
67-
6865 },
6966 error : function (data ) {
7067 new PNotify ({
Original file line number Diff line number Diff line change 3838 text: " {{ trans (' backpack::crud.update_success' ) } }"
3939 });
4040
41- $ (" #{{ $entity } } _edit_modal" ).modal (' toggle ' );
41+ $ (" #{{ $entity } } _edit_modal" ).modal (' hide ' );
4242
4343 // provide auto-fill
4444
6262 setTimeout (function () {
6363 $ (' .select2-results__option' ).trigger (" mouseup" );
6464 }, 200 );
65-
66- console .log (data)
67-
6865 },
6966 error : function (data ) {
7067 new PNotify ({
You can’t perform that action at this time.
0 commit comments