-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support Bootstrap Select (Selectpicker) Library #45
Comments
TL;DR; Here's how to make selectpicker work in Livewire:
Ok, there were two problems contributing to the issue: A. Normal Here is the 2-pronged solution: A. I tagged a new release (v0.0.15) that changes the default listener event to "change" for non-text elements. I think this is a more sensible default
Hope this helps, let me know if it fixed it for you! |
Thanks! It works (sometimes)! I wonder if I'm doing something wrong, but I'm seeing a few issues. It's a bit hard to explain so I made a quick video to show you what's happening: https://www.youtube.com/watch?v=_-LRkPwxdJI To summarize:
|
I started over on this in a new project and I think a lot of the issues I was seeing must have been related to that original project. However, it doesn't seem that this approach works when I am trying to use the selected option from one selectpicker to populate the values of another selectpicker. I can make the original selection just fine, but if I am trying to do this
The problem is, I have the second selectpicker also set to |
I have found a workaround in the console, and maybe you can help me figure out how to implement this programatically. What I'd like to do is run some custom javascript just before livewire swaps out the DOM, then run more custom javascript right after the DOM is swapped. I have looked through the docs at events, but those all seem to just run PHP and not Javascript. This would work
|
There are two "lifecycle hooks" that have been added to the JavaScript
You can find documentation for them here: https://livewire-framework.com/docs/lifecycle-hooks/ |
Hi caleb, this simply doesn´t work for me. I have a livewire component which is a modal and it´s called on a button click that is inside a laravel blade view...everything works great, but the bootstrap-select(selectpicker) it is not rendered, only a normal bootstrap-select, but i need the selectpicker because of the multiple option with the selectAll options...in my app.js i have the: and inside my app.scss i have:
In my web.php i have:
Could you help me out with this please? Reagrds |
I am having the same issue with tail-select
which renders:
|
this works <script> document.addEventListener('DOMContentLoaded', () => { Livewire.hook('element.updating', (fromEl, toEl, component) => { console.log('being update'); $('#type').selectpicker('destroy') }) Livewire.hook('message.processed', (message, component) => { console.log('processed'); $('#type').selectpicker() }) }); </script> |
This only works for the first time I select. When i select it choose it again i get an error. Console: |
For anyone looking, this worked for me. I have 2 selects in a livewire component, from which 2nd one is dependent on first one and its using selectpicker. Here is how i got 2nd one to render correctly with selectpicker |
@cata1818 I tried using the same but suddenly after I select any option and livewire gets updated the select field disappears. What could be the possible reason for this any clue? |
I m not sure why .. i added the code i pasted in my previous comment at the bottom of the livewire component i use. And this livewire component contain just the 2 linked selects and this js code. I remember i had similar issue.. but i think i fixed by using destroy on message.sent and create new instance on message.processed... i played with almost all events and only this worked. |
failing test: Greater than inside @if condition
When you send a request Livewire represents the new DOM as if it were a select what you have to do is the following.
<div>
<select class="selectpicker" >
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
</div>
<div wire:ignore>
<select class="selectpicker">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
</div> When placing the wire:ignore in the div and not in the select, causing the DOM of the select to not update. |
When I create a select input, I can easliy set
wire:model=myVariable
and the data binding works as expected.However, when I use the Selectpicker library the data binding does not work when I make a selection.
I don't know much about how this library works, but here are a few things that might get someone started in the right direction:
selected
attribute on the HTML<option>
. That might get someone pointed in the right direction.The text was updated successfully, but these errors were encountered: