josedaian/select2wire

Select2 for livewire components.

Installs: 66

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

Language:Blade

Type:package

v2.0.1 2023-11-01 20:49 UTC

This package is auto-updated.

Last update: 2024-10-30 01:26:42 UTC


README

josedaian/select2wire Laravel 10 Latest Stable Version Total Downloads License Livewire

Laravel package for handling Select2 inputs for Livewire components.

Requirements

Quick Installation

composer require josedaian/select2wire

For Livewire 2.x version, go here: select2wire v1.x

Usage

Add the following line within your blade view, below the select2.js and jquery.js scripts

@select2wireScript

Within your Livewire component class, call the trait to do one of the functions when loading the component.

use Livewire\Component;
use JoseDaian\Select2\Traits\HasSelect2Wire;

class ExampleComponent extends Component
{
    use HasSelect2Wire;
}

If you don’t have a custom init event, you can call the initSelect2 event directly within your component view.

<div wire:init="initSelect2">
    ...
    <!-- All your selects here -->
</div>

Or in case you already have an init event inside your component, just add the following line

public function customInitFunction()
{
    // your code
    $this->initSelect2();
}

And within your blade view, you’ll need to add the data-select2wire="select2" attribute to your inputs select.

<select data-select2wire="select2">
    <!-- options -->
</select>

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email josedaian.cabrera@gmail.com instead of using the issue tracker.

Credits

Acknowledgments

This package was inspired by livewire-select2.

License

The MIT License (MIT). Please see License File for more information.