Ajax and CForm radio button list uncheckable

Hi all,

I’m addressing an issue with Ajax attributes declared directly in CForm element, expecially on radiolist element.

When i do it, the resoults is that in the brower radio button seem to not be ceckable, when i click on it it blink, fire the ajax function and then come back to a unchecked state.

There is the involved code from the CForm:


'addressReuse' => array (

              'type' => 'radiolist',

              'items' => array (0 => 'same', 1 => 'new'),

              'label' => 'Invoice address',

              'ajax' => array(

                'type' => 'POST', //request type

                'url' => $controller->createUrl('hotelAutocomplete/addressReuse'), //url to call.

                //Style: CController::createUrl('currentController/methodToCall')

                'update' => '#taxes_diva', //selector to update

                //leave out the data key to pass all form values through

              ),

And that’s is the auto-generated jquery script in the source of the page:




jQuery('body').undelegate('#SubscriptionForm_is_business_0','click').delegate('#SubscriptionForm_is_business_0','click',function(){

      jQuery.ajax({

        'type':'POST',

        'url':'/wh/hotelAutocomplete/taxesTypes',

        'cache':false,

        'data':jQuery(this).parents("form").serialize(),

        'success':function(html){

          jQuery("#taxes_div").html(html)

          }

        });

    return false;

    });

  jQuery('body').undelegate('#SubscriptionForm_is_business_1','click').delegate('#SubscriptionForm_is_business_1','click',function(){

    jQuery.ajax({

      'type':'POST',

      'url':'/wh/hotelAutocomplete/taxesTypes',

      'cache':false,

      'data':jQuery(this).parents("form").serialize(),

      'success':function(html){

        jQuery("#taxes_div").html(html)

        }

      });

How can it be solved?

Does it behave the same way if you perform the request using a regular page load rather than an ajax call? If so, there’s something wrong with your server side code. It’s worth using your browser’s developer tools to inspect the data that’s being returned from the server with each ajax request.

You need to set return => true after defining ajax array

‘ajax’ => array(

            'type' => 'POST', //request type


            'url' => $controller->createUrl('hotelAutocomplete/addressReuse'), //url to call.


            //Style: CController::createUrl('currentController/methodToCall')


            'update' => '#taxes_diva', //selector to update


            //leave out the data key to pass all form values through


          ),

‘return’=>true,

@Dinar, thank a lot for the help !