您好,我有兩個問題:
(1)它是在引導文件創建全局自定義函數的最佳實踐?有沒有更好的地方來存放它們?
(2)我無法使用下面的代碼行中位於我的bootstrap.php文件我的自定義功能:
$url = $ajax->link ('Delete', array ('controller' => 'events', 'action' => 'delete', 22), array ('update' => 'event'), 'Do you want to delete this event?');
echo $url;
我收到以下錯誤:
Notice (8): Undefined variable: ajax [APP\config\bootstrap.php, line 271]
Code
}
function testAjax() {
$url = $ajax->link ('Delete', array ('controller' => 'events', 'action' => 'delete', 22), array ('update' => 'event'), 'Do you want to delete this event?');
testAjax - APP\config\bootstrap.php, line 271
include - APP\views\event\queue.ctp, line 19
View::_render() - CORE\cake\libs\view\view.php, line 649
View::render() - CORE\cake\libs\view\view.php, line 372
Controller::render() - CORE\cake\libs\controller\controller.php, line 766
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 211
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 181
[main] - APP\webroot\index.php, line 91
然而,按預期工作,如果我把,我認爲,同樣的代碼:
<a onclick=" event.returnValue = false; return false;" id="link1656170149" href="/shout/events/delete/22">Delete</a>
請幫助:)
在此先感謝!