Zend Framework - 自分のJSプラグインを適用する方法
-
17-09-2020 - |
質問
私のZFパスにある自分のjQueryプラグインを追加する方法 "public / js / isround.js"?
- 手動でこれを入れるのではなく、Zendフレームワークを使用して適用するには:
<script> $("#world").isRound('myPlugin'); </script>
.
-
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');
-
ファイルアプリケーション/ビュー/ 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');
. 所属していません StackOverflow