jquery script

Hi I have the following code to hide comment boxes but it is not working - comment text areas are still showing. Can anyone please help?





Yii::app()->clientScript->registerScript("comment2form", " 

		$('.comment2form').hide();

		$('.add_comment_link').unbind('click');

		$('.add_comment_link').click(function(){

			var id = $(this).attr('id');

			$('.commentform' + id).toggle();

			return false;

		});", CClientScript::POS_READY);






<div id = "commentform<?= $data->pid ?>" class = "comment2form">

<?php

$this->renderPartial(Yum::module('profile')->profileCommentForm, array('comment' => new ProfileCommentComment, 'post' => $data));

?>

</div>



It should work…

could be that you have some other code that is showing the comments again…

Try to remove all other JS code and leave just the


$('.comment2form').hide();

to see if it works…

So the problem is that the jquery script is on the page that CListView widget is feed data to. Is there a way for CListview to respect jquery scripts?

CAN anyone help? please?

If you’re talking about a CListView where pages are updated using Ajax, then of course there will be a problem, since the tags that you initially assign the javascript to will be replaced on Ajax updates.

Either use jQuery live or delegate to assign the events, or look into the afterAjaxUpdate configuration parameter of CListView in order to repeat your javascript assigning whenever there is an Ajax update.