当应用display:none然后display:block to parent div时,Bootstrap模态将不会显示

时间:2017-07-30 19:55:29

标签: jquery twitter-bootstrap-3 modal-dialog bootstrap-modal

这是我的代码。现在我正在使用类col-sm-6更改div的属性,单击一个按钮,使用jquery转动display:none。单击另一个按钮我将其更改回块,但模式不会打开。背景变暗但窗口无法打开。基本上最外层的div显示:none然后显示:block。但模式永远不会改变。什么是可能的解决方案。提前谢谢。

<div class="col-sm-6 col-md-4" id="challange">
                        <div class="alert card alert-dismissible fade show" role="alert">
                            <div class="cardAlert-header">
                                <h5 class="title">Challange</h5>
                                <button type="button" class="close" aria-label="Close">
                                    <i class="fa fa-close" aria-hidden="true"></i>
                                </button>
                            </div>
                            <div class="card-block">
                                <div class="view">
                                    <a class="rounded mx-auto d-block" data-toggle="modal" data-target="#ChartForChallenge">
                                        <img src="img/dashboard/walking-the-dog.svg" class="rounded mx-auto d-block">
                                    </a>
                                </div>
                            </div>
                        </div>
                        <!-- Central Modal Medium Warning -->
                        <div class="modal fade" id="ChartForChallenge" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog modal-notify modal-info modal-lg" role="document">
                                <!--Content-->
                                <div class="modal-content">
                                    <!--Header-->
                                    <div class="modal-header">
                                        <i class="fa fa-bars"></i>
                                        <p class="heading lead">Pet Activity</p>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true" class="white-text">&times;</span>
                                        </button>
                                    </div>
                                    <!--Body-->
                                    <div class="modal-body">
                                        <div class="text-center">
                                            <!-- Nav tabs -->
                                            <ul class="nav nav-tabs md-pills pills-default" role="tablist">
                                                <li class="nav-item">
                                                    <a class="nav-link active" data-toggle="tab" href="#Giorno" role="tab">Giorno</a>
                                                </li>
                                                <li class="nav-item">
                                                    <a class="nav-link" data-toggle="tab" href="#Settmana" role="tab">Settmana</a>
                                                </li>
                                            </ul>
                                            <!-- Tab panels -->
                                            <div class="main-content">
                                                <p class="head">Ogg 10:47AM</p>
                                                <div class="row">
                                                    <div class="col-6">
                                                        <img src="img/dashboard/walking-the-dog.svg" height="120px" width="120px">
                                                        <span class="title">Marco</span>
                                                    </div>
                                                    <div class="col-6">
                                                        <img src="img/dashboard/dog.svg" height="120px" width="120px">
                                                        <span class="title">Fiamma</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="tab-content">
                                                <!--Panel 1-->
                                                <div class="tab-pane fade in show active" id="Giorno" role="tabpanel">
                                                    <br>
                                                    <div id="petHealth" class="chart">
                                                        <svg style="min-height: 220px;"></svg>
                                                    </div>
                                                </div>
                                                <!--/.Panel 1-->
                                                <!--Panel 3-->
                                                <div class="tab-pane fade" id="Settmana" role="tabpanel">
                                                    <br>
                                                    <div id="petHealthDetails" class="chart">
                                                        <svg></svg>
                                                    </div>
                                                </div>
                                                <!--/.Panel 3-->
                                            </div>
                                        </div>
                                    </div>
                                    <!--Footer-->
                                    <div class="modal-footer justify-content-center">
                                        <div class="col-6">
                                            <span>8</span>
                                            <p>Number passed</p>
                                        </div>
                                        <div class="col-6">
                                            <span>18</span>
                                            <p>Number passed</p>
                                        </div>
                                    </div>
                                </div>
                                <!--/.Content-->
                            </div>
                        </div>

1 个答案:

答案 0 :(得分:-1)

如果您愿意,可以尝试使用此代码。

<?php

interface BookOffer {
    function generateCoupon();
    function generateDiscount();
}


class VintageBookOffer implements BookOffer {
    function generateCoupon() {
        return "VINTAGECOUPONCODE";
    }

    function generateDiscount() {
        return 10.0;
    }
}


class NewBookOffer implements BookOffer {
    function generateCoupon() {
        return "NEWBOOKCOUPONCODE";
    }

    function generateDiscount() {
        return 5.0;
    }
}


class OfferGenerator {

    function generateOffer($bookType) {

        if($bookType == "vintage") {
            $bookObject = new VintageBookOffer();
        }
        else if($bookType == "newbook") {
            $bookObject = new NewBookOffer();
        }

        return $bookObject;
    }
}


$bookType1 = "vintage";
$bookType2 = "newbook";


$offerGenerator = new OfferGenerator();
$bookOffer1 = $offerGenerator->generateOffer($bookType1);
$bookOffer2 = $offerGenerator->generateOffer($bookType2);


echo "You chose book type " . $bookType1 . ". Your coupon code is " . $bookOffer1->generateDiscount() . ", and your discount is " . $bookOffer1->generateCoupon();

echo "You chose book type " . $bookType2 . ". Your coupon code is " . $bookOffer2->generateDiscount() . ", and your discount is " . $bookOffer2->generateCoupon();

?>