更改x可编辑的值 [英] Changing the value of x-editable
问题描述
我有一些可用于x-editable的超链接.它们基本上表示可调整大小的div的大小.现在,当我调整div的大小时,我将设置<a>
元素的文本以显示新的大小.问题是当我然后单击超链接并且x-editable出现时,输入的初始值没有根据相应的<a>
元素的新文本值更改.
I have a few hyperlinks that I use with x-editable. They basically represent the size of a resizable div. Now when I resize the div, I'm setting the text of the <a>
elements to display the new size. The problem is when I then click the hyperlinks and x-editable comes in the initial value of the input is not changed according to the new text value of the corresponding <a>
element.
因此,如果初始div大小为400x400,然后将其调整为600x400,则当我单击以编辑宽度时,初始文本框值仍为400.
So if the initial div size is 400x400 and I resize it to 600x400 then when I click to edit the width, the initial textbox value is still 400.
function updateDivSize(div) //this is called whenever the div is being resized
{
//$(context).find(".width-editable").editable('setValue', $(div).width());
//$(context).find(".height-editable").editable('setValue', $(div).height());
$(context).find(".width-editable").text($(div).width());
$(context).find(".height-editable").text($(div).height());
}
现在,如果我每次在a元素上都正常运行时再次在其上调用.editable()
,但是问题是我丢失了所有我希望保留的x-editable的所有其他设置.每次调整div的大小时,是否可以通过其他所有设置再次调用.editable()
来做到这一点?
Now if I call .editable()
on the a elements again each time it works fine, but the problem is that I lose all of the other settings of the x-editable, which I'd like to keep. Is there any way I can do this without calling .editable()
again with all of the other settings every time I resize the divs ?
推荐答案
您需要重新加载X可编辑的函数,但是在删除之前,您需要像这样销毁它:
You need to reload the X-editable function, but before you can du that you need to destroy it like this:
$(".width-editable").editable('destroy');
$(".height-editable").editable('destroy');
我已经编辑了您的JSFiddel,请在此处查看新的JSFiddel: http://jsfiddle.net/xBB5x/9957/
I have edited your JSFiddel, please see the new one here: http://jsfiddle.net/xBB5x/9957/
希望有帮助!
这篇关于更改x可编辑的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!