【发布时间】:2014-12-10 10:17:00
【问题描述】:
在检查了萤火虫后,我的应用程序出现了问题,导致它变慢了 我注意到 jquery-ui 第一次从 google.com 加载两次,第二次从 assets 文件夹 ("232kb") 加载。
如何强制它从没有资产版本的 google.com 加载?
查看内容“JavaScript调用Ajax函数”:
....
$(".third,#second-next,#fourth-pr").click(function () {
$.ajax({
url: '<?php echo Yii::app()->createUrl('site/CallScientificForm',array('language'=>language())); ?>',
type: 'GET',
dataType: 'html',
beforeSend: function () {
$("#loading").show();
},
success: function (data, textStatus, xhr) {
$("#hr3").css("background", "#51a351");
$("*").removeClass("active");
$(".third").addClass("active");
$("#firstContent ,#secondContent,#thirdContent,#fourthContent").fadeOut(2000);
$("#thirdContent").html(data);
$("#thirdContent").fadeIn(2000);
$("#loading").hide();
},
error: function (xhr, textStatus, errorThrown) {
$('#' + id + ' .contentarea').html(textStatus);
},
complete: function() {
$(this).data('requestRunning', false);
}
});
});
...
控制器:
...
public function actionCallScientificForm()
{
$scienceModel = new MembershipScientific();
$view= $this->renderPartial('_ScientificForm', array('scienceModel' => $scienceModel, 'language' => language()), false, true);
echo $view;
Yii::app()->end();
}
..
主要配置:
'clientScript'=>array(
'packages'=>array(
'jquery'=>array(
'baseUrl'=>'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/',
'js'=>array('jquery.js'),
'coreScriptPosition'=>CClientScript::POS_END
),
'jqueryMin'=>array(
'baseUrl'=>'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/',
'js'=>array('jquery.min.js'),
'coreScriptPosition'=>CClientScript::POS_END
),
'jquery-ui'=>array(
'baseUrl'=>'https://code.jquery.com/ui/1.11.1/jquery-ui.min.js',
'js'=>array('jquery-ui.min.js'),
'depends'=>array('jquery'),
'coreScriptPosition'=>CClientScript::POS_END
)
),
),
我在目标视图中这样称呼它:
....
cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerCoreScript('jquery-ui');
....
【问题讨论】: