Dojo和javascript:onclick on anchor选项卡上的轻量级工具提示 [英] Dojo and javascript: lightweight tooltip in onclick on anchor tab
问题描述
格式化程序如下所示:
var descshort = value [1] .substring(0,220);
return'< a href ='+ value [2] +'>'+ value [0] +'< / a>< br />< =gridItemDescription>'+ descshort +'& nbsp;& nbsp;< a href =#onclick =showDesc(); return false;>显示更多...< / a> ; / DIV>';
所以你看到我只显示值[1]的前220个字符。
我现在要做的是显示一个对话框或工具提示,当您点击显示更多...链接具有完整的价值[1](现在有一个showDesc();函数什么都不做)。到目前为止,我已经通过使用以下方式在javascript警报中显示:
onclick =javascript:alert(\' + value [1] +'\'); return false;
而不是一个函数,但我不喜欢警报的样子,特别是在IE中。如果我尝试使用一个函数,我似乎不能在它将获取值[1]数据的地方。有什么东西在Dojo还是javascript我可以在链接中的onclick事件中使用来显示值[1]的内容?
我可以调用一个dojo对话框的函数,并将值作为参数传递给dojo对话框!还需要一段时间才能意识到,在格式化程序中,我需要使用\来转义一些用于构建返回的字符串的字符,同时插入值作为参数。
pre>
elliotDialog = new dijit.Dialog({
标题:我的对话框,
内容:测试内容,
样式: width:450px
});
showDesc = function(layer,layer2){
//设置对话框的内容:
elliotDialog.set(title,layer2);
elliotDialog.set(content,layer);
elliotDialog.show();
};
格式化程序中的onclick如下所示:
onclick =showDesc(\''+ value [1] +'\',\''+ value [0] +'\'); return false ;
I have a dojo datagrid and I am using a formatter that puts, among other things, link in the cell.
The formatter looks like this:
var descshort = value[1].substring(0,220);
return '<a href="'+ value[2] +'">'+value[0]+'</a><br /><div class="gridItemDescription">'+descshort+' <a href="#" onclick="showDesc();return false;">show more...</a></div>';
So you see I am only displaying the first 220 characters of value[1].
What I want to do now is show a dialog or tool tip when you click on the "show more..." link that has the complete value[1] (right now there is a showDesc(); function that does nothing). So far I got it to show up in a javascript alert by using:
onclick="javascript:alert(\' ' + value[1] + ' \');return false;"
instead of a function, but I don't like the way the alert looks, especially in IE. If I try to use a function, I can't seem to but it in a place where it will grab the value[1] data. Is there anything in Dojo or javascript I can use in the onclick event on the link to show the contents of value[1]?
I was able to call a function for a dojo dialog and pass the values as arguments to the dojo dialog! Also it took me a while to realize that in the formatter I need to use \ to escape some of the ' characters that are used to build the returned string while inserting values as arguments.
elliotDialog = new dijit.Dialog({
title: "My Dialog",
content: "test content",
style: "width: 450px"
});
showDesc = function(layer, layer2){
// set the content of the dialog:
elliotDialog.set("title", layer2);
elliotDialog.set("content", layer);
elliotDialog.show();
};
The onclick in the formatter looks like this:
onclick="showDesc(\'' + value[1] + '\',\'' + value[0] + '\');return false;"
这篇关于Dojo和javascript:onclick on anchor选项卡上的轻量级工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!