質問

私のZFパスにある自分のjQueryプラグインを追加する方法 "public / js / isround.js"?
- 手動でこれを入れるのではなく、Zendフレームワークを使用して適用するには:

<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. ファイルアプリケーション/ビュー/ scripts / index / index.phtml、私は:

    _____my JSプラグインはここに適用されます_____

役に立ちましたか?

解決

ビューヘルパーを使用してください。 Zend Documentation チェックアウト: 例2競合モードなしで独自のヘルパーを構築する

ビューヘルパーと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

のインデックスアクション
$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