我有一个带有 5 个选项卡的索引 View 。当我单击 硬件 选项卡时,这就是我所看到的。
当点击创建时,我启动这个模态
我一提交,就收到了警报通知,一切都很好。
但它引导我进入我的第一个标签。
如何重定向回我的第二个选项卡?
存储功能
public function store() {
$inputs = Input::all();
unset($inputs['_token']);
$cpe_mac = $inputs['mac1'].$inputs['mac2'].$inputs['mac3'].$inputs['mac4'].$inputs['mac5'].$inputs['mac6'];
$cpe = [];
$cpe['cpe_mac'] = $cpe_mac;
$cpe['bandwidth_max_up'] = (int)$inputs['max_up'];
$cpe['bandwidth_max_down'] = (int)$inputs['max_down'];
$json = json_encode($cpe);
$url = 'http://172.16.139.129:1234/vse/vcpe';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$result_json = json_decode($result, true);
$id = $inputs['account_id'];
if ( $result_json['status'] == '200') {
return Redirect::to('/account/'.$id.'/#hardware') ->with('success','The CPE was created succesfully!');
} else {
return Redirect::to('/account/'.$id.'/#hardware') ->with('error', $result_json['message']);
}
}
Tab.blade.php
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class=""><a href="#details" data-toggle="tab"><strong>Details</strong></a></li>
<li class=""><a href="#hardware" data-toggle="tab"><strong>Hardware(s)</strong></a></li>
<li class=""><a href="#access-methods" data-toggle="tab"><strong>Access Methods</strong></a></li>
<li class=""><a href="#linked-networks" data-toggle="tab"><strong>Linked Networks</strong></a></li>
<li class=""><a href="#options" data-toggle="tab"><strong>Options</strong></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content mb30">
@include('account.show.details')
@include('account.show.hardwares')
@include('account.show.access-methods')
@include('account.show.linked-networks')
@include('account.show.options')
</div>
最佳答案
您可以提取选项卡名称(#hardware)并将其传递到 View 中。鉴于你可以做这样的事情
<li class="{{ empty($tabName) || $tabName == 'hardware' ? 'active' : '' }}"><a href="#hardware" data-toggle="tab"><strong>Hardware(s)</strong></a></li>
同样在包含的选项卡内容中,您将拥有一个 class="tab-pane"的元素。还要将此条件添加到该元素,例如
<div id="hardware" class="tab-pane {{ !empty($tabName) && $tabName == 'hardware' ? 'active' : '' }}">
关于php - 重定向回 Laravel 中的特定选项卡 Pane ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33747262/