php - Javascript not working when rendering a view using ajax -


my structure looks 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={{ asset('js/jquery.js') }}></script> <script type="text/javascript" src={{ asset('js/scripts.js') }}></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 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 base-layout inside settings.blade.php duplicate sidebar inside main-grid class , js working don't want page inside settings main, want content , js work when rendering it.

i've tried rendersection()['content'] had same results.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -