Laravel,在<p>标签</p>上显示行值

时间:2014-11-27 19:52:13

标签: php laravel blade

我知道这应该很简单,但我不知道该怎么做:

我在数据表上实现了多个“delet”按钮,并希望在对话框中显示一个模态:你是否想要删除:,但我不知道如何放句子。

这是我的观点:

<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <div class="modal-body">
            <div id="message">
                <h3> BORRAR TIPO </h3>

                {{ Form::model($catalog["nambe"], array('method' => 'DELETE', 'id' => 'type', 'route' => array($catalog["name"].'.destroy', $catalog["id"]))) }}

                    <br>
                    <p>Do you reall want to delete: {{ //I whant to display the exactly name of that button }} </p>

                    <br>
                    {{ Form::submit('Save', array('class' => 'btn btn-danger')) }}
                    <button type="button" class="btn btn-info" data-dismiss="modal">Cancel</button>

                {{ Form::close() }}

        </div>
    //mode code below

在我的数据库中,我有:

name of table    |type|
                 |id  |
                 |name|

我想要显示确切类型的名称而不是我按,但不知道该怎么做,有人可以帮我吗?谢谢!

1 个答案:

答案 0 :(得分:0)

这实际上是一个javascript问题。我用这个多次解决了这个问题:

<div class="modal" id="your-modal">
<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <div class="modal-body">
            <div id="message">
                <h3> BORRAR TIPO </h3>

                {{ Form::model($catalog["nambe"], array('method' => 'DELETE', 'id' => 'type', 'route' => array($catalog["name"].'.destroy', $catalog["id"]))) }}

                    <br>
                    <p>Do you reall want to delete: <span id="deleteSentence"></span></p>

                    <br>
                    {{ Form::submit('Save', array('class' => 'btn btn-danger')) }}
                    <button type="button" class="btn btn-info" data-dismiss="modal">Cancel</button>

                {{ Form::close() }}

        </div>

使用此脚本,您可以更改范围的值:

<script>
    $('#your-modal').on('show.bs.modal', function (e) {
        $('#deleteSentence').html($(e.relatedTarget).data('sentence'));
    });
</script>

然后添加调用程序按钮:

<a class="btn" data-toggle="modal" data-sentence="{{$name}}" data-target="#your-modal" href="http://some-url" >Launch Modal</a>

如果您不想随身携带姓名,请在模式中输入隐藏的输入字段。