简体   繁体   中英

Owl Carousel with Magnific Popup - Popup not even displaying, not sure what I'm doing wrong

I'm using Magnific Popup for my Owl Carousel Slider. I just want the images to pop-up on screen. However, it doesn't seem to be working. The only thing it does it when I click the images, it opens up its src link. But I just want the Magnific Popup. Am I importing the files wrong? Am i formatting wrong? I've tried so much and can't seem to get the Magnific Popup to even display...

HTML/PHP

<div class="owl-carousel owl-theme details_banner">
    @forelse($home_images as $image_model)
    @php
    $real_image = public_path('uploads/frontend/home/' . $image_model->name);
    $image = asset('public/uploads/frontend/home/' . $image_model->name);
    if (!file_exists($real_image)) {
    $image=DEFAULT_IMG;
    }
    @endphp    
    
    <a class="popup1" href="<?php echo $image ?>"><img src="<?php echo $image ?>"/></a>
     @empty
    <a a class="popup1" href="<?php echo DEFAULT_IMG ?>"><img src="<?php echo DEFAULT_IMG ?>"/></a>
     @endforelse
</div>

Javascript

<script type ="text/javascript">
    $(document).ready(function() {
        $('.popup1').magnificPopup({
            type: 'image',
            closeOnBgClick :true,
            enableEscapeKey: true
        });    
    });
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="vendor/Magnific-Popup-master/dist/jquery.magnific-popup.min.js"></script>

I put this at the top of my file

<link rel="stylesheet" href="{{asset('public/frontend/css/owl.carousel.min.css')}}" />
<link href="{{asset('public/backend/css/jquery-confirm.min.css') }}" rel="stylesheet">
<!-- Magnific Popup core CSS file -->
<link rel="stylesheet" href="vendor/Magnific-Popup-master/dist/magnific-popup.css" media="screen"/>

Solved by putting these 2 lines above my Magnific Function

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM