Hello,
this is the code i use for creating an activeRadioButtonList that should be bound to an ajax call in order to populate a select.
echo CHtml::activeRadioButtonList(
$model,
"layout_id",
$related,
array(
'separator'=>'',
'ajax'=>array(
'url'=>CHtml::normalizeUrl(array('/campagne/layouter')),
'type'=>'POST',
'replace'=>'#campagne_template_id'
),
'template'=>'{label}{input}'
)
);
The ajax stuff works, the problem is that the javascript code that Yii creates gives me a problem with firefox:
<script type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready(function() {
jQuery('#campagne_nome').live('change',function(){jQuery.ajax({'url':location.href,'cache':false});return false;});
jQuery('#campagne_layout_id_0').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});return false;});
jQuery('#campagne_layout_id_1').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});return false;});
jQuery('#campagne_layout_id_2').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});return false;});
jQuery('#campagne_layout_id_3').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});return false;});
jQuery('#campagne_layout_id_4').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});return false;});
});
/*]]>*/
</script>
this code creates a strange behavior, the checkboxes get never changed. I found out i have to change the code to:
<script type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready(function() {
jQuery('#campagne_nome').live('change',function(){jQuery.ajax({'url':location.href,'cache':false});return false;});
jQuery('#campagne_layout_id_0').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});});
jQuery('#campagne_layout_id_1').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});});
jQuery('#campagne_layout_id_2').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});});
jQuery('#campagne_layout_id_3').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});});
jQuery('#campagne_layout_id_4').live('click',function(){jQuery.ajax({'url':'/index.php?r=campagne/layouter','type':'POST','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#campagne_template_id").replaceWith(html)}});});
});
/*]]>*/
</script>
(ie: remove the return:false;) in order to get the radiobuttons working.
has enyone found out the same thing?
greetings, and thanks,
fredo