【问题标题】:Laravel, show row value on <p> tagLaravel,在 <p> 标签上显示行值
【发布时间】:2014-11-27 19:52:13
【问题描述】:

我知道这应该很容易,但我不知道该怎么做:

我在一个数据表上实现了多个“删除”按钮,并希望在对话框中显示一个模式:Do you real want to delete: ,但我不知道如何放置句子。

这是我的观点:

<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|

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

【问题讨论】:

    标签: php laravel blade


    【解决方案1】:

    这实际上是一个 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>
    

    如果您不想在表单中发送姓名,请在模式中放置一个隐藏的输入字段。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-07
      • 2021-06-26
      • 1970-01-01
      • 2021-10-12
      • 1970-01-01
      • 2022-01-14
      相关资源
      最近更新 更多