[英]How to change ExtJS ToolTip text in runtime?
According to number of questions and articles the simple tip.html = 'new value';
根据问题和文章的数量,简单的tip.html = 'new value';
should work but for some reasons it's not the case for me. 应该工作,但由于某些原因,我不是这样。
Here I have created a demo to demonstrate that tip.html
modification doesn't change tip's body after it was rendered once: 在这里,我创建了一个演示来演示tip.html
修改在渲染一次后不会改变tip的主体:
http://jsfiddle.net/zcYqe/1/ http://jsfiddle.net/zcYqe/1/
Steps to reproduce: 重现步骤:
Scenario 1: 场景1:
Scenario 2: 场景2:
What am I missing? 我错过了什么? How would one change it in runtime (Scenario 1)? 如何在运行时更改它(场景1)?
您不能只设置属性,一旦创建了组件,您需要调用一个方法,以便它实际更新底层DOM:
tip.update('new');
You can accomplish this with a beforeshow
listener in ExtJS 4.2.x (and probably earlier). 您可以使用ExtJS 4.2.x中的beforeshow
侦听器(可能更早)完成此操作。
var changeCount = 1;
var tip = Ext.create('Ext.tip.ToolTip', {
target: 'hoverme',
html: 'Press this button to clear the form',
listeners: {
// Change content dynamically depending on which element triggered the show.
beforeshow: function updateTipBody(tip) {
tip.update( "Changed " + changeCount + " times" );
changeCount ++;
}
}
});
document.getElementById('btn').addEventListener('click', function(e) {
tip.html = 'new';
return false;
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.