我需要知道是否有工具提示填充了数据库中的数据,以便在工具提示中显示。
像工具提示应该包含的东西 name stauts
abc active
xyz active
pqr active
从db
中恢复名称和状态我需要这个工具提示onmouseover,我使用CJSON解码来呈现内容
我确实去谷歌,但几乎没有发现我会彻底理解和实施。
任何人都可以对我们正在寻找的东西有所了解。
答案 0 :(得分:0)
有一个名为yii-bootstrap的扩展程序,清楚地描述了here。
要在此扩展程序中轻松使用工具提示,请查看here。
答案 1 :(得分:0)
我使用cluetip。它与Yii无关,但会给你一些想法:
<强> JS 强>
function renderInfoTips(opts){
var elements=$('#'+opts.form).get(0).elements;
for(i=0; i<opts.tips.length;i++){
$(elements[opts.tips[i].field]).parent().prepend(opts.tips[i].tip);
}
var clue_opts={arrows:true,splitTitle: '|',closePosition: 'title',sticky:true,dropShadow:false,mouseOutClose:true,
onShow:function(ct, ci){
if(!$.browser.webkit) $(ct).css('top',$(ct).position().top- 30+'px');
}
}
$('#'+opts.form).find(".infotip").cluetip(clue_opts);
}
<强> PHP 强>
function setInfoTipsJavascript($form_id,infotips){
if (count($this->infotips) <1 ) return '';
//get all tip names
$names_csv=join(',',array_keys(infotips));
//get tips details from db
$query="select name, description from infotips where FIND_IN_SET(name ,'$names_csv')";
//run the query, in Yii you have to use InfoTipsModel , I have skipped that portion
//$infotipS , lets say this is query object
$tips=array();
while($tip=$infotipS->Assoc()){
$this->infotips[$tip['name']]['tip']="<a href='javascript:void(0)' class='infotip' title='|{$tip['description']}'> </a>";
$tips[]=$this->infotips[$tip['name']];
}
$tips=json_encode($tips);
$script="\nrenderInfoTips({\"form\":'{$form_id}', \"tips\":{$tips}});\n\n";
echo $script;
}
我正在分享这个希望这会给你一些想法。显而易见,您必须:创建信息提示表,模型,并创建窗口小部件等以获取与您的表单字段相关的信息提示。正如有人建议的那样,如果你使用Bootstrap,你有更好的方法来做到这一点。