Git Product home page Git Product logo

laravel-pjax's Issues

Laravel 8 support

Please add support of illuminate/support and illuminate/http ^8.0.
Thanks.

Metas

Hi,

How to update other metas? example: facebook og tags and canonical?

Thanks

not working pjax in my laravel project

hello
i am using pjax in a laravel 8 project but it doesnt work. below i attached my code and a picture of my error.
pleease help me to solve this problem.
thanks

Kernel.php code:

protected $middleware = [
        // \App\Http\Middleware\TrustHosts::class,
        \App\Http\Middleware\TrustProxies::class,
        \Fruitcake\Cors\HandleCors::class,
        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \Spatie\Pjax\Middleware\FilterIfPjax::class,
    ];

link code:

<a data-pjax href="{{route('artists')}}" class="sidebar__nav-link">artists</a>

container code:

<!-- main content -->
<main class="main">
    <div class="container-fluid" id="mainContainerModule">
        @yield('content')
    </div>
</main>

js code:

document.addEventListener('DOMContentLoaded', function(){
        $(document).pjax('[data-pjax] a, a[data-pjax]', '#mainContainerModule');
    });

image

Middleware prority

I have a middleware only apply to a controller but I want my middleware to execute before pjax's middleware.

Example code of my middleware:

public function handle($request, Closure $next)
{
        $booking = session()->get('booking');

        if (!$booking) {
            $request->session()->flash('alert-warning', 'Your session is expired.');

            $request->headers->remove('X-PJAX');

            return redirect()->route('booking.index');
        }

        return $next($request);
}

The purpose of my middleware is to disable PJAX and redirect with normal request if my session variable is empty.

Do you have any idea to achieve this?

How to handle JsonResponses? or is this a bug

I am facing this issue where if session gets expired or an exception gets thrown, the middleware FilterIfPjax::filterResponse throws the following error.

Spatie\Pjax\Middleware\FilterIfPjax::filterResponse() must be an instance of Illuminate\Http\Response, instance of Illuminate\Http\JsonResponse given

What is the best way to handle this problem? I have only noticed this issue when accessing a route using pjax call if the user session gets expired or an exception like UnauthorizedException gets thrown.

handling json response

Symfony\Component\Debug\Exception\FatalThrowableError in GET /applications
Argument 1 passed to Spatie\Pjax\Middleware\FilterIfPjax::filterResponse() must be an instance of Illuminate\Http\Response, instance of Illuminate\Http\JsonResponse given, called in /.../vendor/spatie/laravel-pjax/src/Middleware/FilterIfPjax.php on line 35

I've noticed the issue has already been raised and closed in #29 but it does not seem to be fixed yet and was closed without any explaination so the bug still seems to be there

Typo in readme

Hey, great job with the package.
I saw a typo in the readme and I thought that making a pull request would be a bit much.
The second paragraph says:

The package provides a middleware that can eturn the reponse that the jquery plugin expects.

It should be return of course. ๐Ÿ˜„

Laravel 9 Support

I am trying to install with Laravel 9 but its showing error.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires spatie/laravel-pjax ^2.2 -> satisfiable by spatie/laravel-pjax[2.2.0].
    - spatie/laravel-pjax 2.2.0 requires illuminate/http ^6.0|^7.0|^8.0 -> found illuminate/http[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were 
not loaded, likely because it conflicts with another require.

You can also try re-running composer require with an explicit version constraint, e.g. "composer require spatie/laravel-pjax:*" to figure out if any version is installable, or "composer require spatie/laravel-pjax:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Unprocessable Entity

Hi, I installed the middleware as described in the readme, but in the console on the get request I can see an error: unprocessable entity and then the page redirects.

Please help. Is there something I am missing?

I am using laravel 5.2

Update to Laravel 5.2

laravel-pjax won't install with composer update because Laravel 5.2 uses "symfony/dom-crawler": "~3.0" and "symfony/css-selector": "~3.0", whereas laravel-pjax requires the respective ^2.7 versions.

Laravel 6 support?

Hello, do you plan to update the code to work with Laravel 6?

Thanks!

Not working

HI I followed the instructions but it seems like I have a problem with this.
I imported the js scripts jquery.min.js and jquery.pjax.js in my app.blade.php
I also put this inside in script tag in my app.blade.php
$(document).pjax('a', '#pjax-container');
and put an id pjax-container on my div tag
but everytime I go to the chat link it will still refresh the whole page and vice versa if I go to profile page. I checked the Network in inspect element I got this error
Name : http://circle.dev/profile?_pjax=%23pjax-container
Status: 500 Internal server error

Any idea on how to fix this?
PS. my laravel project is 5.5 I just want to integrate the pjax to load faster

Some views needs to be refreshed to see the correct content (CSS issue?)

Hi,

I use this plugin, but even the vanilla code from Laracasts causes the same issue.

The issue is, some pages, and always the same pages, show incorrect content. The content that is missing is Javascript per page scripts. For example, I have an Orgchart page. This uses Google's Chart API to draw an org chart. It loads on a certain page and initialises the names of the people from a controller that sends data to the view.

Is there an easy workaround?

handling json response

This error still persists even after #33 .
The problem is after #33 the handle method returns Symfony\Component\HttpFoundation\Response whereas some of the functions in the FilterIfPjax class (function filterResponse(), function getCrawler()) expect Illuminate\Http\Response . I have changed the parameter type to use Symfony\Component\HttpFoundation\Response as BaseResponse; in #38

Laravel 7 Support

Installation request for laravel/framework (locked at v7.0.7, required as ^7.0)

Please Update composer

Thanks

resources?

Was just wondering why there is a useless resources folder since this is just a package for the middleware? Great work otherwise :)

install error.

composer require spatie/laravel-pjax
Using version ^2.0 for spatie/laravel-pjax
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install spatie/laravel-pjax 2.0.1
- Conclusion: remove symfony/css-selector v5.0.1
- Installation request for spatie/laravel-pjax ^2.0 -> satisfiable by spatie/laravel-pjax[2.0.0, 2.0.1].
- Conclusion: don't install symfony/css-selector v5.0.1
.....
- Installation request for symfony/css-selector (locked at v5.0.1) -> satisfiable by symfony/css-selector[v5.0.1].

Middleware returns empty content

Hi!

I'm trying to get this set up on a fresh laravel 5.2 installation, however I cannot get it working.
There seems to be a problem with the response not being set to the correct content. The following block of code is responsible:

$response->setContent(
    $this->makeTitle($crawler).
    $this->fetchContainer($crawler, $container)
);

If I check the output of the makeTitle and fetchContainer functions, both correctly extract and return, however all requests come back with empty content (however the correct headers are set).

Any idea what could be causing this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.