Ajax Joomla-OnMouseover使用Qtip脚本在工具提示中显示来自控制器的数据
我需要帮助在鼠标悬停事件的工具提示(使用qTip脚本)中显示数据(来自控制器)Ajax Joomla-OnMouseover使用Qtip脚本在工具提示中显示来自控制器的数据,ajax,joomla,tooltip,qtip,Ajax,Joomla,Tooltip,Qtip,我需要帮助在鼠标悬停事件的工具提示(使用qTip脚本)中显示数据(来自控制器) 链接上的用户鼠标悬停(多个链接,如foreach中的链接) id发送到js函数,如函数getData(id){} 从控制器调用PHP函数&使用变量将数据返回到工具提示 在工具提示中显示返回数据 HTML和PHP: foreach ($rows as $row) { <a href="#" onmouseover="getData(<?php echo $row->id; ?>)" &g
foreach ($rows as $row) {
<a href="#" onmouseover="getData(<?php echo $row->id; ?>)" >Name</a>
}
function getData(id)
{
var url='index.php?option=com_test&controller=test&task=getDetails&format=raw';
var data = 'item_id=' + id ;
var request = new Request({
url: url,
method:'post',
data: data,
async: true,
onSuccess: function(responseText)
{
// How i show the "responseText" data here in tooltip using qTip
}
}).send();
}
function getDetails()
{
echo $return = JRequest::getVar('item_id');
}
控制器功能:
foreach ($rows as $row) {
<a href="#" onmouseover="getData(<?php echo $row->id; ?>)" >Name</a>
}
function getData(id)
{
var url='index.php?option=com_test&controller=test&task=getDetails&format=raw';
var data = 'item_id=' + id ;
var request = new Request({
url: url,
method:'post',
data: data,
async: true,
onSuccess: function(responseText)
{
// How i show the "responseText" data here in tooltip using qTip
}
}).send();
}
function getDetails()
{
echo $return = JRequest::getVar('item_id');
}
在内容项视图覆盖中预加载提示(将其添加到title=属性)并添加对qTip的调用(每页一个)会更容易吗 而且,ajax会使工具提示变得不太快 只需确保在title属性中正确转义“或”字符,否则将破坏标记 编辑:添加了代码。我在这里写这篇文章是为了防止打字错误,但它应该能让你明白:
foreach ($rows as $row) {
// let's assume $tip contains the right tip for each row:
<a href="#" title="<?php echo $tip; ?>" class="tipme">Name</a>
}
现在,如何将值放入$tip?我看到您有一个com_测试组件,您不需要通过控制器,但可以直接实例化将提供工具提示的模型;如果称为“tip”:
本故事中的所有变量、模型和控制器名称都是虚构的。谢谢Riccardo,对不起,您能用一个例子解释一下吗?我还修改了HTML和PHP代码。请检查。