问题描述
我有5个标签的索引视图.当我单击硬件标签时,这就是我所看到的.
I have a index view with 5 tabs. When I click on Hardware tab, this is what I see.
当点击创建"时,我启动该模式
When click on create, I launch this Modal
提交后,我会收到警报通知,一切都很好.
As soon as I submit, I got an alert notification, and everything is store fine.
但这将我定向到我的第一个标签.如何重定向回第二个选项卡?
But it direct me to my first tab.How can I redirect back to my second tab ?
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)并将其传递到视图中.并且您可以执行以下操作
You can extract the tab name(#hardware) and pass it into the view. and in view you can do something like this
<li class="{{ empty($tabName) || $tabName == 'hardware' ? 'active' : '' }}"><a href="#hardware" data-toggle="tab"><strong>Hardware(s)</strong></a></li>
,并且在包含的选项卡内容中,类似地,您将拥有一个带有class ="tab-pane"的元素.还要将此条件添加到该元素中,例如
and similarly in the included tab contents, you will have a element with class="tab-pane". Also add this condition to that element, something like
<div id="hardware" class="tab-pane {{ !empty($tabName) && $tabName == 'hardware' ? 'active' : '' }}">
这篇关于重定向回Laravel中的特定选项卡窗格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!