dimanche 19 avril 2015

For-do loop with accordion in C# MVC?

I'm using Twitter bootstrap's Accordion code in which then I aim to switch theirs with mine.


In my project I am going to have this structure:



Main 2
- Sub 1
- Sub 2
- Sub 3
Main 1
- Sub 1
- Sub 2
- Sub 3


And these increase according to the number there is in a certain database (if there are 4 for example, it will go up to Main 4) Sub1,Sub2,Sub3.... are other Accordions, so I have to have an outer accordion and inner accordions


I am trying to use this code:



@for (int j = 1; j < number; j++ )
{
<div class="panel-group" id="accordion@j">

<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">@j. What is HTML?</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
@j
</div>
</div>
</div>
</div>
</div>

}


where number is how the number from my db


This though does not work. The accordion doesn't work and instead gives me only 2 open divs. The @j changes number accordingly though


any idea what I can do?


Aucun commentaire:

Enregistrer un commentaire