Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass data to Modal? #33

Open
errand opened this issue Jan 13, 2023 · 1 comment
Open

How to pass data to Modal? #33

errand opened this issue Jan 13, 2023 · 1 comment

Comments

@errand
Copy link

errand commented Jan 13, 2023

It's common situation when user clicks on Delete button and confirmation Modal pops up. But i'm stuck passing id to Modal

<x-splade-data>

      <x-splade-table :for="$tags" class="w-2/3">
          <x-splade-cell actions>
              <Link href="#confirm-delete" @click="state.shared.tag = {{ $item->id }}"> {{__('Delete')}} </Link>
          </x-splade-cell>
      </x-splade-table>

    <x-splade-modal :close-button="false" name="confirm-delete">
        <h1>{{ __('Are you sure') }}?</h1>
        <button type="button" @click="modal.close">{{ __('Cancel') }}</button>
        <Link :href=`/dashboard/tag/${data.tag}/delete`> {{__('Delete')}} </Link>
    </x-splade-modal>

</x-splade-data>

Tried both Data and State. And in both cases there is no data in modal

@zulfikar-ditya
Copy link

This is not the best practice but maybe work:

<x-splade-data>

      <x-splade-table :for="$tags" class="w-2/3">
          <x-splade-cell actions>
              <Link href="#confirm-delete-{{$item->id}}" @click="state.shared.tag = {{ $item->id }}"> {{__('Delete')}} </Link>
              <x-splade-modal :close-button="false" name="confirm-delete-{{$item->id}}">
                <h1>{{ __('Are you sure') }}?</h1>
                <button type="button" @click="modal.close">{{ __('Cancel') }}</button>
                <Link :href=`/dashboard/tag/${data.tag}/delete`> {{__('Delete')}} </Link>
            </x-splade-modal>
          </x-splade-cell>
      </x-splade-table>


</x-splade-data>

it will make each data have an modal component. in best practive it should we must to a single modal for deleting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants