2012-12-11 53 views
2

我有一个加载问题,从库jquery ui()方法draggable()。我有一个关于zend framework 2的网站。但由于某种原因,我不明白为什么我的内联代码没有在标签中执行。请帮助!zend框架内嵌/外部js 2.0

文件:parallax.phtml - 布局页面(应用程序/视图/布局/ parallax.phtml

<?php echo $this->doctype(); ?> 
<html lang="en"> 

     <head> 
      <meta charset="utf-8"/> 

      <?php echo $this->headTitle('alfared.zend.ua');?> 
      <?php echo $this->headMeta() 
          ->appendName('Content-Type','text/html;charset=utf-8') 
          ->appendName('description','fsdfsafsa') 
          ->appendName('X-UA-Compatible','IE=edge,chrome=1') 
          ->appendName('viewport','width=device-width,initial-scale=1.0') 
          ->appendName('keywords','')?> 
     <?php echo $this->headLink()->prependStylesheet($this->basePath() . '/css/parallax.css') 
       ->prependStylesheet($this->basePath() . '/css/style.css') 
       ->prependStylesheet($this->basePath() . '/css/flexslider.css') 
       ->prependStylesheet($this->basePath(). '/css/bootstrap.min.css') 
       ->prependStylesheet($this->basePath(). '/css/jquery-ui.css') 
     ?> 

     <?php echo $this->headScript() 
      ->prependFile($this->basePath().'/js/html5.js','text/javascript', array('conditional' => 'lt IE 9')) 
     ?> 
      <?php $script =" //<--inline script 
       $(function() { 
         $('#draggable').draggable(); 
       }); 
     "?> 
     <?php echo $this->headScript()->prependFile($this->basePath(). '/js/jquery-1.8.3.js','text/javascript')?> 
     <?php echo $this->headScript()->prependFile($this->basePath(). '/js/jquery-ui.js')?> 
     <?php echo $this->headScript()->prependScript($script,'text/javascript') ?> 
      <style type="text/css">#draggable{ 
       width: 150px; 
       height: 150px; 
       padding: 0.5em; 
      }</style> 
     </head> 

回答

3

尝试使用inlinescript view helper

<?php echo $this->inlineScript()->appendScript(<<<EOT 
$(function() { 
    $('#draggable').draggable(); 
}); 

EOT 
); ?>