I'm using Yii::app()->clientScript to register script; In php file, I wrote script in multiply line, but when it register to browser, every script file will put on a line, include my comment, this will make error because everything after // will be know as comment.Script after transfer is something like this: tag.firstChild.onchange=function(){ load_grid(obj); }; } //Comment ....It has only one line.Please help me.
Update: This is an example:
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('//maps.googleapis.com/maps/api/js?sensor=false', CClientScript::POS_HEAD);
$cs->registerScript('googlemaps_api','
function geocode(address, lat_id, lng_id) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address: address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
$("#"+lat_id).val(results[0].geometry.location.lat());
$("#"+lng_id).val(results[0].geometry.location.lng());
} else alert("'.Yii::t('views/config/edit_store_locations_options','ERROR_GEOCODE_ADDRESS').'");
});
}
', CClientScript::POS_HEAD);