문제

어떻게 내 zf 경로 "public / js / isround.js"에 자신의 jquery 플러그인을 추가 할 수 있습니까?
- 수동으로 Zend Framework를 사용하여 적용하려면 수동으로 다음을 넣는 대신 :

<script> $("#world").isRound('myPlugin'); </script>
.

  1. jQuery 설정이 작동 중입니다

    $this->jQuery()->setLocalPath('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js')
                   ->enable()
                   ->setUiLocalPath('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js')
                   ->uiEnable()
                   ->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/ui-lightness/jquery-ui.css');
    
  2. 파일 응용 프로그램 / 뷰 / 스크립트 / index / index.phtml, 나는 가지고 있습니다 :

    _____my JS 플러그인이 여기에 적용됩니다 _____

도움이 되었습니까?

해결책

뷰 도우미를 사용하십시오. 젠드 문서 체크 아웃 : 예제 # 2 충돌 모드가없는 자신의 도우미를 구축

또한 ViewHelpers 및 JQuery의 튜토리얼 Zendcast

여기에 몇 가지 코드가 있습니다. MyLib라는 라이브러리 폴더에 폴더를 만듭니다. 폴더보기를 만듭니다. 보기에서 폴더 도우미를 만듭니다. 도우미에서 이름이 지정된 파일을 만듭니다. isround.php

<?php

class Mylib_Views_Helpers_IsRound {
    public function isRound($elem){
        echo '<script type="text/javascript">$("'.$elem.'").isRound();</script>';
    }
}
.

indexcontroller.php의 indexAction

$this->view->addHelperPath('Mylib/views/helpers', 'Mylib_Views_Helpers');
.

index.phtml :

<?php $this->isRound('#elem'); ?>
.

희망이 도움이됩니다!

다른 팁

이거 찾고있는 것입니까?

$this->headScript()->appendFile('/js/isround.js');
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top