My structure looks like this
head.blade.php
<html class="no-js">
<head>
<title></title>
</head>
<body class="page">
@include('layouts.sidepanel')
sidepanel.blade.php
div class="sidebar">
<ul>
<li>
<a href="#" class="menu-item" onclick="getPages({method: 'page',httpMethod: 'GET',uri: 'page',});">Page</a>
</li>
</ul>
</div>
foot.blade.php
<script type="text/javascript" src=></script>
<script type="text/javascript" src=></script>
</body>
</html>
base-layout.blade.php
@extends('layouts.head')
<main class="with-footer">
<div class="row main-grid">
@yield('content')
</div>
</main>
@include('layouts.foot')
the controller
public function getSettings() {
$settings = DB::table('settings')->get();
$returnHTML = view('settings')->with('settings', $settings)->render();
if($request->ajax()) {
return response()->json(array('success' => true, 'data'=>$returnHTML));
}
}
settings.blade.php
@extends('layouts.base-layout')
@section('content')
<p>Test</p>
@endsection
and this javascript function
function getPages(params) {
$.ajax({
type: params.httpMethod,
url: params.uri
}).done(function (data) {
switch (params.method) {
default:
if (data.success) {
if (data.data) {
$('.main-grid').html(data.data).fadeIn();
}
}
break;
}
})
}
Extending the base-layout inside settings.blade.php will duplicate the sidebar inside the main-grid class and the js is working but I don't want to another page inside settings exactly like the main, I just want the content and the js to work when rendering it.
I've also tried renderSection()['content'] but had the same results.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire