Here is the plain HTML code which is working and want to move this to Yii framework .
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(function() {
$.get("dist_list.html",
function(dist){
$("#sourceModels").html(dist);
});
});
</script>
</head>
<body>
<select id="sourceModels" size="20" ></select>
</body>
</html>
in the above code I am calling dist_list.html which is simple list
<option value='1'>AAA</option>
<option value='2'>BBB</option>
<option value='3'>CCC</option>
<option value='4'>DDD</option>
<option value='5'>EEE</option>
<option value='6'>FFF</option>
To Move this work to Yii framework , I moved java script code to a .js file and the dist_list.html copied to /components/js folder ( Both .js and html in the same folder)
in view I am calling registering the script using
Yii::app()->clientScript->registerScriptFile(
Yii::app()->assetManager->publish(
Yii::getPathOfAlias('application.components').'/js/models.js'
),
CClientScript::POS_END
);
which is working fine . I even checked this by putting some alert statements java script
and using the below drop down list code
<?php echo CHtml::dropDownList("sourceModels", '',array(),array('class'=>'mandal','size'=>20) );?>
But the dropdown box is not getting the options from the html file which is getting called from Java script . I tried few paths changing when calling java script .
Could some one please help me on this ?
I am using the HTML just to load the options ( These options are fixed and even if there are changes max one ..two times) instead of database to save database calls . Any best approach you can suggest ? ( Don't want to copy them in the model ...)
Thank You
Regards
Kiran
include()statement.