Monday, 19 August 2013

Cakephp generated javascript throws error onclick

Cakephp generated javascript throws error onclick

I have a group of tests in my system. It is possible for a test to be
paused. On the index page of my test controller, I use the following code
to display the tests.
<table>
<tr><th>ID</th><th>Name</th><th>Updated</th><th>Actions</th></tr>
<?php foreach ($tests as $test): ?>
<tr>
<td>
<?php echo $test['Test']['id']; ?>
</td>
<td class="actions">
<?php
$status = ($test['Test']['is_paused'] == 1) ? 'Un-pause' :
'Pause';
echo $this->Form->postLink($status,
array('controller'=>'tests', 'action' => 'pause',
$test['Test']['id'], 'admin' => 1), array('confirm'=>'Are you
sure?') );
?>
<?php
echo $this->Html->link('Edit', array('controller'=>'tests',
'action' => 'edit', 'admin'=>1, $test['Test']['id']));
?>
<?php
echo $this->Form->postLink('Delete',
array('controller'=>'tests', 'action' => 'delete',
$test['Test']['id'], 'admin'=>1), array('confirm'=>'Are you
sure?') );
?>
</td>
</tr>
<?php endforeach; ?>
</table>
This generates a list of tests and provides some action functions for each
one using postlink from the cakephp form helper. The one that is causing
problems is the pause button. Sometime when clicked it throws the
following error.
Uncaught TypeError: Object #<HTMLCollection> has no method 'submit'
I'm not super up on my JS and since the JS for this is automatically
built, I'm not sure how to fix this. The pause button will do nothing when
this issue occurs and I'm not even sure where to start debugging this.
Thank you to anyone who helps.

No comments:

Post a Comment