The requirement is to do a no-refresh sort, show hidden
Routing:
Route::p ost (' Cate/changeorder ', ' [email protected] '); Route::p ost (' Cate/changeshow ', ' [email protected] ');
Controller:
//Change Sort Public functionChangeorder () {$input= Input::All (); $cate= Goodscates::find ($input[' cate_id ']); $cate->order =$input[' Cate_order ']; $re=$cate-update (); if($re){ $data= [ ' Status ' + 0, ' msg ' = ' + ' sort update succeeded! ‘, ]; }Else{ $data= [ ' Status ' = 1, ' msg ' = ' + ' sort update failed, please try again later! ‘, ]; } return $data; } //Change Show hidden Public functionchangeshow () {$input= Input::All (); $cate= Goodscates::find ($input[' cate_id ']); $cate->is_bean =$input[' Cate_order ']; $re=$cate-update (); if($re){ $data= [ ' Status ' + 0, ' msg ' = ' state updated successfully! ‘, ]; }Else{ $data= [ ' Status ' = 1, ' msg ' = ' failed, please try again later! ‘, ]; } return $data; }
Use Illuminate\support\facades\input;
Front page:
<Scripttype= "Text/javascript"> functionChangeorder (obj,cate_id) {varCate_order=$ (obj). val (); $.post ("{{URL (' Admin/cate/changeorder ')}}",{'_token':'{{Csrf_token ()}}','cate_id': cate_id,'Cate_order': Cate_order},function(data) {layer.msg (data.msg); }); } //Show Hidden functionChangeshow (obj,cate_id) {varCate_order=$ (obj). val (); $.post ("{{URL (' Admin/cate/changeshow ')}}",{'_token':'{{Csrf_token ()}}','cate_id': cate_id,'Cate_order': Cate_order},function(data) {layer.msg (data.msg); }); }</Script>
@foreach ($cates as $cate)<TR> <TD><inputstyle= "Width:26px;text-align:center;"onchange= "Changeorder (this,{{$cate->id}})"type= "text"name=""value= "{{$cate->order}}"></TD> <TD>{{$cate->id}}</TD> <TD>{{$cate->name}}</TD> <TD><Selectonchange= "Changeshow (this,{{$cate->id}})"ID= "Isbean" > <optionvalue= "0"{{$cate->Is_bean = = 0? ' Selected ': '}}> is</option> <optionvalue= "1"{{$cate->Is_bean = = 1? ' Selected ': '}}> no</option> </Select></TD> <TD> <Divclass= "Btn-group"> <ahref= "{{action (' Admin\[email protected] ', $cate->id}}"class= "btn btn-xs btn-default-bright">Modify</a> <ahref= "javascript:;"class= "btn btn-xs btn-default-bright deluser"Data-url= "{{action (' Admin\[email protected] ', $cate->id}}"Data-method= "Del"data-msg= "Confirm Delete?">Delete</a> </Div> </TD> </TR>@endforeach
Laravel No Refresh reorder + control Show hidden