douzhan1031 2012-02-22 14:55
浏览 63
已采纳

Yii在ajax请求上卸载bootstrap插件

i installed this extension http://www.cniska.net/yii-bootstrap/ , is possible when i make an ajax request to unload from 'preload'=>array('bootstrap','log'), : bootstrap ,i don't need to use bootstrap on ajax request , how to avoid that

<link rel="stylesheet" type="text/css" href="/tamada/assets/97e8be51/css/bootstrap.min.css" />
Content updated in AJAX<script type="text/javascript" src="/tamada/assets/cb84ef9f/jquery.min.js"></script>
<script type="text/javascript" src="/tamada/assets/97e8be51/js/bootstrap-button.js"></script>
<script type="text/javascript" src="/tamada/assets/97e8be51/js/bootstrap-tooltip.js"></script>
<script type="text/javascript" src="/tamada/assets/97e8be51/js/bootstrap-popover.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
jQuery('a[rel="tooltip"]').tooltip();
jQuery('a[rel="popover"]').popover();
/*]]>*/
</script>

Thank You A LOT , sorry for my english

  • 写回答

2条回答 默认 最新

  • douyou7102 2012-02-24 18:05
    关注

    You can selectively load it in your config/main.php.

    This might not be the best PHP but it should work. Basically, when loading the config, check whether the request is an AJAX request or not using Yii::app()->request->isAjaxRequest.

    Add to top of config/main.php:

    <?php
    
    // Load it by default
    $preload = array('bootstrap');
    
    // Don't load it for AJAX requests
    if (Yii::app()->request->isAjaxRequest) {
        $preload = array();
    }
    

    Then pull in the module (either toggled on or off) using array_merge:

    // preloading 'log' component (with selective bootstrap component)
    'preload'=>array_merge(array('log'), $preload),
    

    Now when you do an AJAX request to your application the bootstrap module should not be loaded.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算