fix: redirects user on selection
This commit is contained in:
@@ -20,8 +20,10 @@ export default class extends Controller {
|
||||
_onPreConnect(event) {
|
||||
// TomSelect has not been initialized - options can be changed
|
||||
console.log(event.detail.options); // Options that will be used to initialize TomSelect
|
||||
event.detail.options.onChange = (value) => {
|
||||
// ...
|
||||
event.detail.options.onItemAdd = (value, $item) => {
|
||||
console.log(value, $item)
|
||||
const params = value.split('|')
|
||||
window.location.href = `/result/${params[0]}/${params[1]}`
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Monitor\Action\Command\MonitorTvShowCommand;
|
||||
use App\Monitor\Action\Handler\MonitorTvShowHandler;
|
||||
use App\Monitor\Framework\Scheduler\MonitorDispatcher;
|
||||
use App\Tmdb\Tmdb;
|
||||
use App\Tmdb\TmdbResult;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -41,9 +42,10 @@ final class IndexController extends AbstractController
|
||||
$tmdbResults = $tmdb->search($term);
|
||||
|
||||
foreach ($tmdbResults as $tmdbResult) {
|
||||
/** @var TmdbResult $tmdbResult */
|
||||
$results[] = [
|
||||
'text' => $tmdbResult->title,
|
||||
'value' => $tmdbResult->title,
|
||||
'value' => "$tmdbResult->mediaType|$tmdbResult->imdbId",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
<div class="relative">
|
||||
<form id="search" action="{{ path('app_search') }}">
|
||||
<select
|
||||
{{ stimulus_controller('symfony/ux-autocomplete/autocomplete', {url: path('app_test'), create: false, highlight: false}) }}
|
||||
{{ stimulus_controller('search_bar') }}
|
||||
{{ stimulus_controller('search_bar')|stimulus_controller('symfony/ux-autocomplete/autocomplete', {url: path('app_test'), create: false, highlight: false}) }}
|
||||
name="term"
|
||||
class="w-full bg-orange-500 rounded-md bg-clip-padding backdrop-filter
|
||||
backdrop-blur-md bg-opacity-40 placeholder:text-slate-200 text-gray-50
|
||||
|
||||
Reference in New Issue
Block a user