Saturday, April 1, 2017

Use bootstrap modal for delete confirmation (laravel blade)

My goal is to use bootstrap modal as delete confirmation. But the problem is i need to transfer a dynamic variable (which contains item ID) value to bootstrap modal for submit post request to delete that specific item. Please check Modal Part where value="foo" is set now tell me how can i make this "foo" as dynamic variable which will be comming from laravel blade template part ("Delete") Whats the solution? I prefer javascript solution.

Bootstrap Modal Part

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">Are you sure?</h4>
                </div>
                <form method="post">
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <button type="submit" class="btn btn-primary" name="delete_dividend" value="foo">Delete</button>
                </div>
                </form>
            </div>
        </div>
    </div>

Laravel Blade Template Part

@foreach($dividends_10 as $_dividend_data)
                    <tr>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td><a href="dividends">Edit</a></td>
                      <td><a href="#" data-toggle="modal" data-target="#myModal">Delete</a></td>
                    </tr>
                  @endforeach



via Kaka Doe

Advertisement