Hi.  I'm still somewhat new, and tinkering around with the tutorial
blog application, and having some trouble when trying to create an
ajax-ified comment submission form, specifically with the url that the
form ends up submitting to.  This is the code I'm using for the form:

<?=$form->create('Comment',
array('url'=>array('controller'=>'comments', 'action'=>'add'))); ?>
<?=$form->input('Comment.name');?>
<?=$form->input('Comment.content');?>
<?=$form->input('Comment.post_id', array('type'=>'hidden', 'value'=>
$post['Post']['id']));?>
<?=$this->Js->submit('Add
Comment',array('update'=>'comments','url'=>array('controller'=>'comments',
'action'=>'add')),false);?>
<?=$this->Js->writeBuffer();?>

When I use this (with the jQuery JS engine), this JS is generated:
$(document).ready(function () {$("#submit-1025595286").bind("click",
function (event) {$.ajax({data:$
("#submit-1025595286").closest("form").serialize(), dataType:"html",
success:function (data, textStatus) {$("comments").html(data);},
type:"post", url:"\/posts\/comments\/add"});

The issue is the url there; that should be just /comments/add , rather
than /posts/comments/add . When I use a string instead for the URL in
the code ('url' => '/comments/add'), the URL is what I expect.  Is
there something I'm missing with the array notation?

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to