Giter Site home page Giter Site logo

Comments (8)

Tofandel avatar Tofandel commented on August 16, 2024 2

@lepikhinb The issue is that inertia only filters out lazy prop one level deep

        $props = ($only && $request->header('X-Inertia-Partial-Component') === $this->component)
            ? Arr::only($this->props, $only)
            : array_filter($this->props, static function ($prop) {
                return ! ($prop instanceof LazyProp);
            });

So that means that under 'modal.props' they will always be evaluated because they won't be filtered

So for this to work you filter the lazy props yourself before sharing them, I'll make a PR

from momentum-modal.

jeffreyvanhees avatar jeffreyvanhees commented on August 16, 2024

It would be great if something like this worked. I can think of many situations where functionality like this is needed, like refreshing a dropdown or something.

from momentum-modal.

lepikhinb avatar lepikhinb commented on August 16, 2024

This should already work, as it just utilizes the Inertia's share method to pass modal props.

inertia()->share(['modal' => $this->component()]);
protected function component(): array
{
    return [
        'props' => $this->props,
        ...
    ];
}

from momentum-modal.

funkymonk91 avatar funkymonk91 commented on August 16, 2024

Running into this today.

I'm trying to get data after the initial page load using Inertia.reload({ only: ['jobsForDropdown'] }) on the front end.

public function edit(Project $project)
{
    return Inertia::modal('Projects/Jobs/Edit', [
        'jobsForDropdown' => Inertia::lazy(
            fn () => SomeService::getJobs()
                ->map(fn ($p) => [
                    'value' => $p['id'],
                    'label' => $p['name']
                ])
        ),
        ...
     ])->baseRoute('projects.edit', $project);
}

It's always there. Even on first load :S.

from momentum-modal.

jeffreyvanhees avatar jeffreyvanhees commented on August 16, 2024

I have the same problem as @funkymonk91. When reloading data with Inertia::reload({only: ['var1', 'var2']});, it won't update the data.

from momentum-modal.

Tofandel avatar Tofandel commented on August 16, 2024

Btw unrelated, can I ask, why did you add basePageRoute in 08aea53 ? It's the same function as baseRoute didn't you mean to create as baseUrl method instead

from momentum-modal.

lepikhinb avatar lepikhinb commented on August 16, 2024

@Tofandel it replicates the method from the official implementation that was never released yet.

from momentum-modal.

limsocheat avatar limsocheat commented on August 16, 2024

Hi, I noticed lazy props are not possible with the modal thingy:

public function create(): Modal
{
    return Inertia::modal('Admin/Classrooms/Create')
        ->with([
            'closureLazy' => fn () => User::all(),
            'inertiaLazy' => Inertia::lazy(fn () => User::all()),
        ])
        ->baseRoute('admin.classrooms.index');
}

How difficult is to add this behaviour, does it differ much from the original behaviour that Inertia has?

P.S. Love your work.

Hi, I have the same issue. Did you manage to get it work?

from momentum-modal.

Related Issues (20)

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.