on ajax success clear green css

hi.

first post :)

how do i clear the green row (class success) on ajax success.

many thanks

Can you paste the code you’re currently using? Either way, when the ajax call is successful (providing you’re using jQuery), it triggers a success() function (see: http://api.jquery.com/jQuery.ajax/). Within that function you’d just have to remove the success class, i.e.


$.ajax({

  url: 'blah',

  success: function() {

    $('.your_selector').removeClass('success');

  }

})

Don’t try to use that code, as it won’t just plug in to what you currently have :P Hopefully though it should give you an idea.

The other solution would be to change the CSS rule… so that even if there is class “success” it’s not green

Thanks (Artificial)… thats the sort of thing that way i use the green as a reminder that the form is dirty and need submiting and thus cleared once sucessfull

I thought it a good practice to post the final code for others.




//make the form with unique id

<div class="form" id='group<?php echo $group->id_Group;?>'>

<?php $form = $this->beginWidget('CActiveForm', array(

    'id'=>'group',

    'enableAjaxValidation'=>true,

    'enableClientValidation'=>true,

    'clientOptions' => array(

			  'validateOnSubmit'=>true,

			  'validateOnType'=>false,

	),

    'focus'=>array($group,'groupName'),

)); ?>

	<?php echo $form->errorSummary($group); ?>


	<?php echo CHtml::hiddenField('form','group');?>

	<div class="row">

		<?php echo $form->labelEx($group,'groupName'); ?>

                <?php echo $form->textField($group,'groupName', array('style' => 'width: 581px')) ?>

		<?php echo $form->error($group,'groupName'); ?>

	</div>


	<div class="row buttons">

		<?php

		echo CHtml::ajaxSubmitButton(

			'save',

			array(),

			array(

			'data'=>'js:jQuery(this).parents("form").serialize()+"&ajax=1"',

                        'success'=>"function()

				{

				$('#group" . $group->id_Group . "').find('.row').removeClass('success');

				} ",

				

			)

		);

		?>

	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->