Jquery plugins jQuery自动省略号插件-不';更新内容时无法工作
我正在使用以下jQuery插件: ,一般来说,它工作得很好。 当我需要更新元素的文本时,问题就出现了。我们可以假设,更改元素的文本并再次调用插件将执行与初始调用相同的操作 但是,从中可以看出,事实并非如此 代码非常简单Jquery plugins jQuery自动省略号插件-不';更新内容时无法工作,jquery-plugins,Jquery Plugins,我正在使用以下jQuery插件: ,一般来说,它工作得很好。 当我需要更新元素的文本时,问题就出现了。我们可以假设,更改元素的文本并再次调用插件将执行与初始调用相同的操作 但是,从中可以看出,事实并非如此 代码非常简单 var container = $(".container"); container.text("This is a long text that should have text ellipsis"); //this works fine
var container = $(".container");
container.text("This is a long text that should have text ellipsis");
//this works fine
container.ellipsis();
$("button").click(function()
{
container.text("This is the modified text that should also have ellipsis");
//this doesn't work
container.ellipsis();
});
我能让它工作的唯一方法是删除元素上存储的数据,然后
让插件“从头开始”运行
有什么想法吗?清除自动省略号存储的数据:container.data('jqae',null)
谢谢你,弗雷德里克。但这正是我在问题中所说的——“我能让它工作的唯一方法是删除存储在元素上的数据”。我正在寻找一个更好的想法,它是API本身所支持的。无论如何,谢谢你。
var container = $(".container");
container.text("This is a long text that should have text ellipsis");
//this works fine
container.ellipsis();
$("button").click(function()
{
container.data('jqae', null);
container.text("This is the modified text that should also have ellipsis");
//this doesn't work
container.ellipsis();
});