Support the ongoing development of Laravel.io →
posted 9 years ago
Views Blade
Last updated 2 years ago.
0

One quick solution can be to use a flag to check for the first foreach value something like this:


@if(flag==<some_value>)
       ....
      <reset flag>
       ....
      <div id="{{$special->id}}" class="panel-collapse collapse in">

               <div class="panel-body">
                                    {{ $special->content }}
               </div>
     </div>
@else
       .....
       .....
      <div id="{{$special->id}}" class="panel-collapse collapse">
                     <div class="panel-body">
                                    {{ $special->content }}
               </div>
     </div>

@endif

Or if you know the value returned by $special->id, you can compare that.

Last updated 9 years ago.
0

you could always use the :first-child css selector and target the first accordian and give it classes that make accordian open..

0

I'm not able to do that and if I try to use jquery my alert doesn't happen.

jquery

$(".panel-title a").click(function(){
    alert("yay");
  });
0

Did you wrap the jquery in a document ready callback?

0

yes I did

0

I use this snippet for the same thing:

<div id="" class="panel-collapse collapse {{ ($special == head($content->special)) ? 'in' : '' }}">
    ...
</div>
0

I've tried what you suggested but it doesn't pick up the statement

0

What do you mean? Is there an error? Are the closed accordions shown? Is anything shown?

0

There is no error, the accordions is still closed and when I check firebug I still have

<div id="2" class="panel-collapse collapse ">
0

Sign in to participate in this thread!

Eventy

Your banner here too?

shiva shiva Joined 24 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.