mehr
(Hamed)
1
Hello,
I’m using ListView to create a navigation list. navigation list is based on <ul> and <li>
In the resulting html output there are additional div tags surrounding every model output. like:
<div id="w1"> <div data-key="4"><li><a href="#Abrar">Abrar</a></li></div>
which are generated automatically.
Is there any way to prevent ListView from generating this additional divs?
Or is there any other way too loop through Models(rendering a view file) other than using ListView widget?
Thanks in advance.
Bizley
(Bizley)
2
Yes, just like mentioned here http://www.yiiframework.com/doc-2.0/guide-output-data-widgets.html#listview you can set your own view file with everything rendered just like you want it.
mehr
(Hamed)
3
Couldn’t figure it out to have ListView functionality to word while it doesn’t generate <div data-key=“index”> tags
I solved it out by not using ListView and instead looping directly through Models and generating html.
sirpyerre
(Pedrorojas)
4
You can put to false tag index in ‘itemOptions’:
ListView::widget([
'dataProvider' => $listDataProvider,
'itemView' => '_list_item',
//'emptyText' =>'',
'summary' => '',
'itemOptions' => [
'tag' => false
],
'options' => [
'class' => 'news-v2 margin-bottom-50',
'id' => false
]
]);