如何在工具提示消息中包含图标
How to include the icon inside the tooltip message
我需要在工具提示消息中包含下载图标,我试过以下代码:
ObjectIconView: Ember.ContainerView.extend(childMOMixin, {
iconDownload: function () {
model: 'download'
},
mouseEnter: function(e) {
if(type == 'Text'){
var textUrl = {content: 'Preview is Not Available, Use '+ this.iconDownload() +'Menu'};
this.$().tooltip(textUrl);
}
}
因为我在工具提示中调用了 iconDownload
。但它在输出中说 undefined
。我使用的是 Ember 1.4.0 版本。任何人都可以为此提供建议。我是 Ember 的新手。提前致谢
为了让工具提示显示您期望的数据,您需要更改两处。
1:Return 来自 iconDownload
的内容
现在,函数 returns 什么都没有,它生成一个内部列表然后什么都不做。
它甚至需要是一个函数,还是可以只是一个字符串、对象?
2:您没有正确访问其中的数据。
假设您实际上需要返回一个散列,那么您没有正确访问数据 - 您所做的只是获取对象。
使用您现在拥有的结构,您的字符串生成器将是
'Preview is Not Available, Use '+ this.iconDownload().model +'Menu'
如果可能的话,我建议进行一些额外的更改。
1:使用Ember getter从iconDownload获取数据。
调用 this.get('iconDownload.model')
或 this.get('iconDownload')
而不是 this.iconDownload
2:使实际的工具提示文本成为计算的 属性。
toolTipText: function () {
return `Preview is Not Available, Use ${this.get('iconDownload.model')} Menu`;
}.property('iconDownload.model');
现在,您只需调用 this.get('toolTipText') 即可获得工具提示的内容。
3:将您的 mouseEnter 函数移动到视图 javascript
的操作部分
我需要在工具提示消息中包含下载图标,我试过以下代码:
ObjectIconView: Ember.ContainerView.extend(childMOMixin, {
iconDownload: function () {
model: 'download'
},
mouseEnter: function(e) {
if(type == 'Text'){
var textUrl = {content: 'Preview is Not Available, Use '+ this.iconDownload() +'Menu'};
this.$().tooltip(textUrl);
}
}
因为我在工具提示中调用了 iconDownload
。但它在输出中说 undefined
。我使用的是 Ember 1.4.0 版本。任何人都可以为此提供建议。我是 Ember 的新手。提前致谢
为了让工具提示显示您期望的数据,您需要更改两处。
1:Return 来自 iconDownload
的内容
现在,函数 returns 什么都没有,它生成一个内部列表然后什么都不做。
它甚至需要是一个函数,还是可以只是一个字符串、对象?
2:您没有正确访问其中的数据。
假设您实际上需要返回一个散列,那么您没有正确访问数据 - 您所做的只是获取对象。
使用您现在拥有的结构,您的字符串生成器将是
'Preview is Not Available, Use '+ this.iconDownload().model +'Menu'
如果可能的话,我建议进行一些额外的更改。
1:使用Ember getter从iconDownload获取数据。
调用 this.get('iconDownload.model')
或 this.get('iconDownload')
2:使实际的工具提示文本成为计算的 属性。
toolTipText: function () {
return `Preview is Not Available, Use ${this.get('iconDownload.model')} Menu`;
}.property('iconDownload.model');
现在,您只需调用 this.get('toolTipText') 即可获得工具提示的内容。
3:将您的 mouseEnter 函数移动到视图 javascript
的操作部分