Adding page-specific Javascript to each view in CakePHP

前端 未结 9 1129
余生分开走
余生分开走 2020-12-28 09:35

In an attempt to keep my scripts maintainable, I\'m going to move each into their own file, organised by controller and action:

// scripts which only apply t         


        
9条回答
  •  囚心锁ツ
    2020-12-28 09:46

    There's a nuts and bolts of CakePHP blog post on Convention over Configuration – what's the big deal? - which uses a helper for specifying Javascript files:

    Javascript->link($this->_jqueryPath . '/' .
                                        $this->_pageScriptPath .'/' .
                                        $this->params['controller'] . '_' .
                                        $this->params['action'], false);
        }
    
    }
    
    ?>
    

    And then you just have $jsManager->myJs(); in your view.

提交回复
热议问题