php - 重定向回 Laravel 中的特定选项卡 Pane

标签 php laravel redirect laravel-5 laravel-5.1

我有一个带有 5 个选项卡的索引 View 。当我单击 硬件 选项卡时,这就是我所看到的。
enter image description here
当点击创建时,我启动这个模态
enter image description here
我一提交,就收到了警报通知,一切都很好。
enter image description here
但它引导我进入我的第一个标签。
如何重定向回我的第二个选项卡?

存储功能

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/

相关文章:

php - 请求的链接库 openssl 安装了错误的版本

php - 如何使用 HTML 和 PHP 在字段的下拉列表中添加新项目?

Laravel 5.1 Eloquent 地尝试插入数据库而不是更新

reactjs - React Router Dom Redirect 需要刷新页面才能工作

php - Memcache php cli vs apache 使用不同的缓存?

php - 服务器的 Google API 身份验证

php - 如何在 Laravel 5 中处理 PDOException

php - Laravel 创建复合外键时出错

mysql - Apache2 允许用户连接到 IP (Raspberry PI)

php - 如何使用 .htaccess 将所有页面重定向到 https,但有异常(exception)?