Tuesday, May 3, 2011

$this->Ajax->Form Question to avoid double submit

Hi,

I have a form like this:
<?php echo $this->Ajax->Form('comment', 'post', array('update' =>
'msg', 'url' => array('action' => 'comment'))); ?>
<input type="submit" value="save" id="submitcomment">
<?php echo $this->Ajax->Form->end(); ?>

Using jquery I use this function:
$('#submitcomment').click(function() {

if($("#comm").val().length < 20) {
alert('too short');
return false;
}else{
// do some other things when comment long enough...
return true;
}

But comment action is called twice and I don't understand why...
Can anyone help me out?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: