[英]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? 是否可以加载包含其自己的
CSS
和js
的整个刀片服务器?
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">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</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.