ajax更新后更新sIFR文本
-
02-10-2019 - |
题
我在我的网站中使用 sIFR 版本 3。我正在使用来自 ajax 请求的 id“points”更新 div 中的文本。我想更新文本并在文本更改后将 sIFR 应用于该 div。
请提出一个解决方案。
这是我的更新代码
new Ajax.Request('score.php', {
onSuccess: function(response) {
$('points').update(response.responseText);
}
});
解决方案 3
感谢您的意见 。 AJAX更新后,我发现了一种使用SIFR的方法。
new Ajax.Request('score.php', {
onSuccess: function(response) {
$('points').update(response.responseText);
$('points').removeClassName('sIFR-replaced');
applySIFR();
}
});
applysifr();函数再次应用所有SIFR替换。我认为从元素中删除“ SIFR重新装置”的类是使其正常工作的关键。
其他提示
这样的事情:
new Ajax.Request('score.php', {
onSuccess: function(response) {
$('points').update(response.responseText);
sIFR.replace(font, {
selector: '#points'
});
}
});
步骤1, 用 jQuery 替换 sIFR 的 parseSelector 当您编写以下内容时,它也适用于 Prototype:
var parseSelector = $$; // prototypes querySelectorAll implementation.
这为您在 sIFR 中提供了更多选择器功能,因为它的默认实现相当有限。
读 'sIFR3 文档' 如何使用 sIFR3。
您现在应该在 sIFR 实例中拥有所有可用的 jQuery 选择器,因此下一步就是发挥创意。
new Ajax.Request('score.php', {
onSuccess: function(response) {
$('points').update(response.responseText);
sIFR.replace({src:'yourFont.swf'}, {
selector: '#points h1' // any selector you want.
});
}
});
不隶属于 StackOverflow