Code Html du Modèle de la Boîte de ne pas fonctionner en boucle dans laravel vue

J'en veux pour preuve les textes dans la page web à l'aide de la boucle avec html Modal Box.textes enregistrés dans la base de données.Je suis à l'aide de framework laravel.afficher uniquement modal box pour le premier élément, peut-être il peut être JavaScript pas de problème de chargement. J'ai utilisé https://www.w3schools.com/howto/howto_css_modals.asp Modale de la boîte de tutoriels.utilisé que css et le code javascript.

juste utilisé w3schools code.

<div class="row">
    @foreach($dw as $ad)
        <!-- single product -->
        <div class="col-lg-4 col-md-6">
            <div class="single-product">
                <!--{{$ad->image}}-->
                <div>
                    <img class="img-fluid" src="{{ asset('img/' . $ad->image) }}" alt="">
                </div>

                <div class="product-details">
                    <h3 col-xl-5>{{$ad->jobtype}}</h3>
                    <div class="price col-xl-11">
                        <h6 col-xl-12>{{$ad->jobC}}</h6>
                        <div>
                            <button id="myBtn">Details</button>

                            <!-- The Modal -->
                            <div id="myModal" class="modal">

                                <!-- Modal content -->
                                <div class="modal-content">
                                    <span class="close">&times;</span>
                                    <p>{{$ad->details}}</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="prd-bottom"><a href="{{url('/submitcv')}}">Send Your CV</a></div>
                </div>
            </div>
        </div>
    @endforeach   

pas d'erreurs montrer, mais pas de travail modal box pour tous les jeux, indiquant uniquement le premier élément de la boucle

0
2019-09-17 11:46:40
source
1 réponses

Vous pouvez utiliser le package extensible

code complet

import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Expandable Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  State createState() {
    return MyHomePageState();
  }
}

class MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("About DTC"),
      ),
      body: ListView(
        children: <Widget>[
          Text(
            loremIpsum,
            softWrap: true,
            overflow: TextOverflow.fade,
          ),
          Card1(),
          Card2(),
        ],
      ),
    );
  }
}

const loremIpsum =
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";

class Card1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ExpandableNotifier(
        child: ScrollOnExpand(
      scrollOnExpand: false,
      scrollOnCollapse: true,
      child: Padding(
        padding: const EdgeInsets.all(10),
        child: Card(
          clipBehavior: Clip.antiAlias,
          child: Column(
            children: <Widget>[
              ScrollOnExpand(
                scrollOnExpand: true,
                scrollOnCollapse: false,
                child: ExpandablePanel(
                  tapHeaderToExpand: true,
                  tapBodyToCollapse: true,
                  headerAlignment: ExpandablePanelHeaderAlignment.center,
                  header: Padding(
                      padding: EdgeInsets.all(10),
                      child: Text(
                        "Service",
                        style: Theme.of(context).textTheme.body2,
                      )),
                  collapsed:
                      Container(), //Text('Service', softWrap: true, maxLines: 2, overflow: TextOverflow.ellipsis,),
                  expanded: Column(
                    children: <Widget>[
                      Row(
                        children: <Widget>[
                          Expanded(
                            child: Column(children: <Widget>[
                              ListTile(title: Text('Item ')),
                            ]),
                          ),
                          Expanded(
                            child: Column(children: <Widget>[
                              ListTile(title: Text('Item ')),
                            ]),
                          )
                        ],
                      ),
                      Row(
                        children: <Widget>[
                          Expanded(
                            child: Column(children: <Widget>[
                              ListTile(title: Text('Item ')),
                            ]),
                          ),
                          Expanded(
                            child: Column(children: <Widget>[
                              ListTile(title: Text('Item ')),
                            ]),
                          )
                        ],
                      ),
                      Row(
                        children: <Widget>[
                          Expanded(
                            child: Column(children: <Widget>[
                              ListTile(title: Text('Item ')),
                            ]),
                          ),
                          Expanded(
                            child: Column(children: <Widget>[
                              ListTile(title: Text('Item ')),
                            ]),
                          )
                        ],
                      ),
                    ],
                  ),
                  builder: (_, collapsed, expanded) {
                    return Padding(
                      padding: EdgeInsets.only(left: 1, right: 1, bottom: 1),
                      child: Expandable(
                        collapsed: collapsed,
                        expanded: expanded,
                        crossFadePoint: 0,
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    ));
  }
}

class Card2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ExpandableNotifier(
        child: ScrollOnExpand(
      scrollOnExpand: false,
      scrollOnCollapse: true,
      child: Padding(
        padding: const EdgeInsets.all(10),
        child: Card(
          clipBehavior: Clip.antiAlias,
          child: Column(
            children: <Widget>[
              ScrollOnExpand(
                scrollOnExpand: true,
                scrollOnCollapse: false,
                child: ExpandablePanel(
                  tapHeaderToExpand: true,
                  tapBodyToCollapse: true,
                  headerAlignment: ExpandablePanelHeaderAlignment.center,
                  header: Padding(
                      padding: EdgeInsets.all(10),
                      child: Text(
                        "Contact",
                        style: Theme.of(context).textTheme.body2,
                      )),
                  collapsed:
                      Container(), //Text("Contact", softWrap: true, maxLines: 2, overflow: TextOverflow.ellipsis,),
                  expanded: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Padding(
                          padding: EdgeInsets.only(bottom: 10),
                          child: Text(
                            'Address : 5F',
                            softWrap: true,
                            overflow: TextOverflow.fade,
                          )),
                    ],
                  ),
                  builder: (_, collapsed, expanded) {
                    return Padding(
                      padding: EdgeInsets.only(left: 1, right: 1, bottom: 1),
                      child: Expandable(
                        collapsed: collapsed,
                        expanded: expanded,
                        crossFadePoint: 0,
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    ));
  }
}

enter image description here

+1
2019-09-17 12:07:37

Voir d'autres questions sur les étiquettes