简体   繁体   English

Laravel:是否可以将刀片视图加载到jQuery模式中?

[英]Laravel: Is it possible to load blade view into a jquery modal?

Below is my main blade file that I want to load into modal. 以下是我要加载为模式的主要刀片文件。

@extends('layouts.app')

@section('title', trans('pages.jobs.show.header_title') ?: trans('pages.jobs.show.title'))

@section('navigation')

@endsection

@section('content')
    <div class="container">
        <div class="page-dashboard">
            {{ all teh content loaded: such as SVG grapgh using JS }}
        </div>
    </div>

    <nav class="container-fluid nav-bottom" data-js="nav-bottom">

        <div class="nav-bottom__overlay"></div>

    </nav>    

    @push('scripts')
        <script src=""></script>
    @endpush
@endsection

I have tried using bootstarp.js modal but the modal is not loading, it loads in the main page. 我尝试使用bootstarp.js模态,但是模态未加载,它加载在主页中。

Is it possible to load an entire blade with its own CSS and js included? 是否可以加载包含其自己的CSSjs的整个刀片服务器?

Kindly provide me any example. 请给我任何例子。 Maybe, I have to use ajax: 也许,我必须使用ajax:

$('#modellink').click(function(){

            $.ajax({
                type : 'GET',
                url : $(this).data('path'),

                success: function(result, url) {

                    $('.modal-body').html(result);
                    $('#myModal').modal('show');

                    $('.modal-container').load($(this).data('path'),function(result){
                        $('#myModal').modal({show:true});
                    });
                }
             });
        });

Return the HTML string 返回HTML字符串

// SomeController::getModal()
return view('layouts.someview', $data_array)->render();

Load it into the modal 加载到模态

 $.ajax(
  // blah,
  // blah,
  success: function(response) {
    $('#modal').html(response)
  }
)

If you have a file call modal.blade.php , which has all the HTML, CSS and JS for that modal, you can include it on any page with @include("modal") . 如果您有一个名为modal.blade.php的文件,其中包含该模式的所有HTML,CSS和JS,则可以使用@include("modal")将其包含在任何页面上。 For example: 例如:

modal.blade.php

<style>...</style>

<div class="modal fade" tabindex="-1" role="dialog">
    <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">Modal title</h4>
            </div>
            <div class="modal-body">
                <p>One fine body&hellip;</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">...</script>

Then, in your main file: 然后,在您的主文件中:

main.blade.php

@extends("layout")
@section("content")
@include("modal")
<div>...</div>

In short - yes. 简而言之-是的。

Im not sure how you're loading your modal - as you don't provide much information, but, if you can load an external page into your modal, then simply point to the laravel route that displays your blade view. 我不确定您如何加载模态-因为您没有提供太多信息,但是,如果您可以将外部页面加载到模态中,则只需指向显示刀片视图的laravel路线即可。

Alternatively, use an @include('modal.name.blade') and have that as part of the page which uses the modal with the correct html/css of course for your relevant modal script. 或者,使用@include('modal.name.blade')并将其作为页面的一部分,该页面使用与相关模态脚本正确的html / css模态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过laravel中的ajax / jquery将blade或php内容加载到视图中? - How to load blade or php content into a view via ajax/jquery in laravel? 在页面中将另一个 laravel 刀片视图显示为模式 - Display another laravel blade view as a modal in a page Laravel .blade视图将无法加载 - Laravel .blade view won't load 是否可以在刀片视图中使用groupBy在laravel中进行分页? - Is it possible to do pagination in laravel with groupBy in blade view? Laravel如何加载视图刀片并将其与DOMDocument一起使用? - Laravel how to load a view blade and use it with `DOMDocument`? Laravel 将 integer 值显示为 modal-view.blade 中的字符串 - Laravel display integer value into string in modal-view.blade Laravel自动将头/页脚加载到视图的最佳方法(不带刀片) - laravel best way to automatically load a head/footer to a view (without blade) 是否可以在Blade View(Laravel)中检索数据库记录? - Is it possible to retrieve database records inside a Blade View (Laravel)? 是否可以在Laravel(4)刀片模板中获取视图/布局名称 - Is it possible to get the view / layout name in a Laravel (4) blade template 是否可以在 laravel 中返回具有两个变量的视图(使用刀片)? - Is it possible to return a view (using blade) with two variables in laravel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM