Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OctoberCMS - How to make collapsible list default to active only on non-mobile

I have an OctoberCMS site and I am trying to hide a sidebar in a collapsible list so that when viewed on mobile the list item will be collapsed. When not on mobile I'm looking for it to be expanded as in the example below:

http://codepen.io/anon/pen/GoqPJj

The code is below:

<div class="container">
    <div class="row">
        <div class="col s12 m6">
            <ul class="collapsible" data-collapsible="accordion">
                <li>
                    <div class="collapsible-header active"><i class="material-icons">filter_drama</i>First</div>
                    <div class="collapsible-body">
                        <p>Lorem ipsum dolor sit amet.</p>
                    </div>
                </li>
            </ul>
        </div>
        <div class="col s12 m6">
            This is the main page content. Here is some more content, and here is some even more content. It never seems to end as I add random text. Just one more sentence to make it a bit more complete.
        </div>
    </div>
</div>

Does anyone know how I can edit the above example to produce the desired outcome?

like image 211
user2694306 Avatar asked Dec 22 '15 22:12

user2694306


1 Answers

Here is the code that work as per your requirement. Here i have define $( document ).width() as 420. You can change it as per your requirement.

if($( document ).width() < 420){
  $('.collapsible-body').hide();
  $('.active').removeClass('active');
  }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.2/css/materialize.min.css">
    
    
    <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
  <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.2/js/materialize.min.js'></script>

<div class="container">
	<div class="row">
		<div class="col s12 m6">
			<ul class="collapsible" data-collapsible="accordion">
				<li>
					<div class="collapsible-header active"><i class="material-icons">filter_drama</i>First</div>
					<div class="collapsible-body">
						<p>Lorem ipsum dolor sit amet.</p>
					</div>
				</li>
			</ul>
		</div>
		<div class="col s12 m6">
			This is the main page content. Here is some more content, and here is some even more content. It never seems to end as I add random text. Just one more sentence to make it a bit more complete.
		</div>
	</div>
</div>

Hope this will work for you.

Enjoy !!!! Thanks

like image 155
Bhavin Solanki Avatar answered Oct 23 '22 02:10

Bhavin Solanki