CakePHP: Custom Function in bootstrap that uses $ajax->link not working

Posted by nekko on Stack Overflow See other posts from Stack Overflow or by nekko
Published on 2010-03-23T06:37:24Z Indexed on 2010/03/23 6:43 UTC
Read the original article Hit count: 316

Filed under:
|

Hello I have two questions:

(1) Is it best practice to create global custom functions in the bootstrap file? Is there a better place to store them?

(2) I am unable use the following line of code in my custom function located in my bootstrap.php file:

    $url = $ajax->link ( 'Delete', array ('controller' => 'events', 'action' => 'delete', 22 ), array ('update' => 'event' ), 'Do you want to delete this event?' );
    echo $url;

I receive the following error:

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

However it works as intended if I place that same code in my view:

<a onclick=" event.returnValue = false; return false;" id="link1656170149" href="/shout/events/delete/22">Delete</a>

Please help :)

Thanks in advance!!

© Stack Overflow or respective owner

Related posts about cakephp

Related posts about php