开发者

Zend Framework: How to give specific order to javascript files and scripts

开发者 https://www.devze.com 2023-03-17 07:46 出处:网络
I have following javascript files included in layout: $this->InlineScript()->appendFile($this->baseUrl(\'resource/js/jquery.js\'));

I have following javascript files included in layout:

$this->InlineScript()->appendFile($this->baseUrl('resource/js/jquery.js'));
$this->InlineScript()->appendFile($this->baseUrl('resource/js/main/login.js'));
$this->InlineScript()->offsetSetFile(3,$this->baseUrl('resource/js/core.js'));

I have following script in view file:

<?php $this->InlineScript()->captureStart() ?>
    alert('This is Inline Script in View');
<?php $this->InlineScrip开发者_开发知识库t()->captureEnd() ?>

Right now, my script in view file, is inserting before all javascript files.

How can I insert my inline script before 'core.js' and after 'login.js' file


in layout you can used appendFile() and prependFile() combinations,if you will have some place for file...

and...

in "layout.phtml":

<?php echo $this->inlineScript(); ?>

in "test.phtml":

<?php $this->inlineScript()->captureStart() ?>
alert('This is Inline Script in View');
<?php $this->inlineScript()->captureEnd() ?>

result:

<html>
<head>
<script type="text/javascript">
//<!--
alert('This is Inline Script in View');
//-->
</script>  
</head>
0

精彩评论

暂无评论...
验证码 换一张
取 消