Level 75
Get whatever page they were on in the request. And using JavaScript window location redirect to that page in your js. You will have to add the page as part of your response.
Using pagination. When a user deletes an item on page >=2 they are taken back to page 1 versus left on the page they were on.
I need to keep the user on the page that they were on.
How do I do this?
Here is the code for the JS and controller function:
Javascript
$(document).on('click','.removeFromAuction', function(event) {
var itemid = $(this).attr('itemid');
var show = $("#show option:selected").val();
$.ajax({
url:"/removeitemfromauction",
data:{show:show, itemid:itemid},
success:function(data_return)
{
$('#auction_items_pagination').html(data_return);
}
});
});
Controller function
function removeitemfromauction(Request $request)
{
$result = DB::table('auctionitems')
->where('coin_id', '=', $request->itemid)
->delete();
if($result){
$errormsg = 0;
}
else{
$errormsg = 1;
}
$items = DB::table('coins')
->select(DB::raw('coins.id, auctionitems.auction_id, auctionitems.item_reserve, coins.series, coins.year, coins.mint, coins.rating, coins.rating_group, coins.notable_value_description, coins.purchase_price_total, coins.retail_value'))
->leftJoin('auctionitems', function($join){
$join->on('auctionitems.coin_id', '=', 'coins.id');
})
->where('user_email', '=', auth()->user()->email)
->orderBy('coins.id', 'asc')
->paginate($request->show);
return view('auction.auction_items_pagination_data', compact('errormsg','items'))->render();
}
Get whatever page they were on in the request. And using JavaScript window location redirect to that page in your js. You will have to add the page as part of your response.
Please or to participate in this conversation.