Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP: Custom Function in bootstrap that uses $ajax->link not working
    primarykey
    data
    text
    <p>Hello I have two questions:</p> <p>(1) Is it best practice to create global custom functions in the bootstrap file? Is there a better place to store them?</p> <p>(2) I am unable use the following line of code in my custom function located in my bootstrap.php file:</p> <pre><code> $url = $ajax-&gt;link ( 'Delete', array ('controller' =&gt; 'events', 'action' =&gt; 'delete', 22 ), array ('update' =&gt; 'event' ), 'Do you want to delete this event?' ); echo $url; </code></pre> <p>I receive the following error:</p> <pre><code>Notice (8): Undefined variable: ajax [APP\config\bootstrap.php, line 271] Code } function testAjax () { $url = $ajax-&gt;link ( 'Delete', array ('controller' =&gt; 'events', 'action' =&gt; 'delete', 22 ), array ('update' =&gt; '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 </code></pre> <p>However it works as intended if I place that same code in my view:</p> <pre><code>&lt;a onclick=" event.returnValue = false; return false;" id="link1656170149" href="/shout/events/delete/22"&gt;Delete&lt;/a&gt; </code></pre> <p>Please help :) </p> <p>Thanks in advance!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload