When I select football it shows the football data, then when I select dance it shows the dance data but football data not shown where football is checked. I don't know why this problem has happened.
Here is my code:
blade file
@foreach ($featured as $playlist)
<li class="lib">
<!-- <a class="open-library" href="{{ route('public.playlist', $playlist->slug) }}">{{{ $playlist->name }}}</a> -->
<a>
<input type="checkbox" class="open-library" name="" id="{{ $playlist->id}}" data-value="{{ $playlist->slug}}">{{ $playlist->name}}
</a>
</li>
@endforeach
js file
$(".open-library").change(function () {
var val = $(this).data('value');
var id = $(this).attr('id');
if ($(this).is(":checked") == true) {
$(":checked").serialize();
$.get("{{url('/playlist')}}/" + val, function (data) {
refreshedPage = $(data);
newDemo = refreshedPage.find(".libraryWrapper ").html();
$('.libraryWrapper').html(newDemo);
});
} else {
$.get("{{url('/playlist')}}/" + val, function (data) {
refreshedPage = $(data);
newDemo = refreshedPage.find("load-more-pagination").html();
//$('.load-more-pagination').hide();
$(".load-more-pagination").hide(newDemo);
});
}
});
controller
public function getProject($slug)
{
$sortBy = Input::get('sortBy', 'reference');
$dir = Input::get('direction', 'asc');
$id = UniqHash::unhash($slug);
$project = Project::whereId($id)->first();
if (!$project) {
return Redirect::route('home');
}
$tracks = null;
if ($project->tracks) {
$ids = json_decode($project->tracks, true);
$tracks = Element::with('composers', 'format_mp3s', 'loopsets.format_mp3s', 'mixes.format_mp3s', 'opening_key', 'closing_key', 'speed', 'mood', 'metre', 'tonic')
->whereIn('id', $ids)
->orderBy($sortBy, $dir)
->get();
}
$this->layout->content = View::make('public.projects.show', compact('project', 'tracks'));
}