Git Product home page Git Product logo

livewire-plugin's People

Contributors

daftspunk avatar kold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

dheia kold

livewire-plugin's Issues

Livewire 3 Issues

Tried to use Livewire 3 with this plugin but I've found a couple of issues:

  • Styles and Scripts needs to be compiled with a new class
  • Livewire::mount method now returns the compiled string, calling ->html() causes a error
  • I can only use .blade.php views, twig / .htm does't work anymore (I didn't manage to solve this)

If it helps I can make a pull request for the first two items, the way I maintained compatibility with v2 is checking if the old classes still exists, like this:

LivewireHelper.php

    public static function renderStyles($options = [])
    {
        if (method_exists('\Livewire\LivewireManager', 'styles')) {
            return Livewire::styles($options);
        }
        return \Livewire\Mechanisms\FrontendAssets\FrontendAssets::styles($options);
    }
    public static function renderScripts($options = [])
    {
        $turboScript = Url::asset('plugins/rainlab/livewire/assets/js/livewire-turbo.js');

        if (method_exists('\Livewire\LivewireManager', 'scripts')) {
            if (!isset($options['asset_url'])) {
                $options['asset_url'] = Url::asset('');
            }

            $scriptStr = Livewire::scripts($options);
        } else {
            $scriptStr = \Livewire\Mechanisms\FrontendAssets\FrontendAssets::scripts($options);
        }

        $scriptStr = str_replace('data-turbolinks-eval="false"', '', $scriptStr);

        $scriptStr .= "<script> addEventListener('page:loaded', function() { if (window.oc && oc.useTurbo && oc.useTurbo() && !window.Livewire) window.location.reload(); }, { once: true }); </script>";

        $scriptStr .= '<script src="' . $turboScript . '" data-turbo-eval="false"></script>';

        return $scriptStr;
    }

Plugin.php - register()

        if (method_exists('\Livewire\LivewireManager', 'setScriptRoute')) {
            Livewire::setScriptRoute(function ($handle) {
                return Route::get(Url::asset('/livewire/livewire.js'), $handle);
            });
        }

LivewireNode.php - compile()

        if (class_exists('\Livewire\LifecycleManager')) {
            $compiler
                ->write(")->html();\n");
        } else {
            $compiler
                ->write(");\n");
        }

404 on loaded Livewire js script

I have a 404 error on the livewire script js (so it doesn’t work). In my case OC is installed in a subfolder, and even if I set the link policy to force, its trying to get the file without taking into account the whole path with the subfolder in it.

The script is added like this (without the whole path):
<script src="/livewire/livewire.js?id=90730a3b0e7144480175" data-turbo-eval="false" data-turbolinks-eval="false" ></script>

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.