【问题标题】:modal dont open in codeigniter模态不会在 codeigniter 中打开
【发布时间】:2020-12-03 17:22:27
【问题描述】:

我正在尝试创建一个模式,但是当我在基本域中时它会打开,例如:

模态在www.example.com中打开

但未在中打开

www.example.com/index.php/cart/index 我不知道为什么

    <div id="myModal" class="modal fade">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4>Select your language</h4>                       
            </div>
            <!--<section>-->
                <div class="modal-body">
                    <div class="col-md-4">
                    <a href="https://www.w3schools.com"><img width=128px height=128px src="https://image.flaticon.com/icons/png/128/323/323329.png" alt="" class="img-responsive none" style='object-fit: contain'/></a>
                    <p>English</p>
                    </div>
                    <div class="col-md-4">
                        <img width=128px height=128px src="https://image.flaticon.com/icons/png/128/323/323329.png" alt="" class="img-responsive none" style='object-fit: contain'/>
                        <p>English</p>
                        </div>
                        <div class="col-md-4">
                            <img width=128px height=128px src="https://image.flaticon.com/icons/png/128/323/323329.png" alt="" class="img-responsive none" style='object-fit: contain'/>
                            <p>English</p>
                            </div>
                <div class="tab_img">
                    
                        <div class="container" style='height: 100%; width: 100%; object-fit: contain'>
                                
                                <div class="overlay">
                                </div>
                            </a>    
                        </div>
                    </div>
                    </div>
                </div>
            
            <!--</section>-->
        </div>
        </div>
    </div>
    </div>

激活模态的脚本

<script type="text/javascript">
    jQuery(document).ready(function($) {
        $(".scroll").click(function(event){     
            event.preventDefault();
    
    
    $('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
        });
    });
</script>{/literal}
{literal}<script>
$(document).ready(function(){
    $("#myModal").modal('show');
});
</script>

【问题讨论】:

  • 你有没有检查过首页加载的脚本在购物车/索引中是否相同。您还可以在购物车/索引中发布您如何触发此模式吗?谢谢
  • {literal}&lt;script type="text/javascript"&gt; jQuery(document).ready(function($) { $(".scroll").click(function(event){ event.preventDefault(); $('html,body').animate({scrollTop:$(this.hash).offset().top},1000); }); }); &lt;/script&gt;{/literal} {literal}&lt;script&gt; $(document).ready(function(){ $("#myModal").modal('show'); }); &lt;/script&gt;{/literal}
  • @RicardoMartins 请使用您在评论中添加的 javascript 代码编辑您的帖子。
  • 我已经用脚本更新了
  • 检查所有源文件,如引导 css 和 js 文件以及 jquery。我认为您的 cuuent 页面中缺少这些文件。或者您可以在控制台中检查错误,然后进行相应操作。

标签: html css codeigniter modal-dialog


【解决方案1】:

你检查过Routes.php吗?

$routes->get('/', 'Cart::index');

希望这能解决您的问题。

【讨论】:

  • 当我将它添加到我的 router.php 时,它只会给我一个 codeigniter 错误
  • 我想我可能发现了问题,它没有加载 www.example.com/index.php/cart/index 中的 css 文件,我不知道原因
【解决方案2】:

尝试在 config.php 中检查您的 base_url()。 问题可能是您没有正确加载 css。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 2022-01-25
    • 1970-01-01
    • 1970-01-01
    • 2017-03-06
    • 1970-01-01
    • 2016-05-05
    相关资源
    最近更新 更多