使用Slim框架将输出渲染到Modal

时间:2019-06-20 14:43:03

标签: twitter-bootstrap slim

我正在创建一个网页,该网页将在 访问网站时,每个服务器的类型都是按钮,因此当 用户单击按钮,它必须调用该函数(getHostDetails) 并在模式div标签中显示输出,如下所示

单击按钮({i.sname}}-服务器名称)时,它必须调用 通过传递参数({{i.sID}}-函数“ getHostDetails”- 服务器ID)和此功能的输出应显示在 低于模式div。

我正在使用Slim Framework 3.x

下面的部分包含html代码:

<tr>
    {% for i in srvcontainer  %}
    <td class="text-center h9 th-sm">
        <a href="/showinfo/{{i.sID}}">
        <button type="button" id="button1" class="btn btn-info btn-dark btn-sm" data-toggle='modal' data-target="#info">{{i.sname}}</button>
        </a>
    </td>
    {% endfor %}
</tr>

<div id='info' class='modal fade' role='dialog'>
    <div class='modal-dialog modal-lg'>
        <div class='modal-content'>
            <div class='modal-header'>
                <button type='button' class='close' data-dismiss='modal'>&times;</button>
                <h4 class='modal-title'>Test</h4>
            </div>
             <div class='modal-body'>
             {% for h in srvinfo  %}
                 <tr><td>{{h.CPU}}</td><td>{{h.Memory}}</td></tr>
             {% endfor %}
            </div>
            <div class='modal-footer'>
                <button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
            </div>
        </div>
    </div>
</div>

包含以下代码index.php

$app->get('/', function ($request, $response) use ($app) {
    $wp = new reports();
    $wps = $wp->getHosts();
    return $this->view->render($response, 'wps.html', array(
        "wps" => $wps));
});

$app->get('/showinfo/{sID}', function ($request, $response, $args) use ($app) {
    $wp = new reports();
    $wsid = $args['sID'];
    $srvinfo = $wp->getHostDetails($wsid);
    return $this->view->render($response, 'wps.html', array(
        "srvinfo" => $srvinfo));
});

为此寻求帮助。

0 个答案:

没有答案