简体   繁体   English

更改x可编辑的值

[英]Changing the value of x-editable

I have a few hyperlinks that I use with x-editable. 我有一些用于x-editable的超链接。 They basically represent the size of a resizable div. 它们基本上表示可调整大小的div的大小。 Now when I resize the div, I'm setting the text of the <a> elements to display the new size. 现在,当我调整div的大小时,我将设置<a>元素的文本以显示新的大小。 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. 问题是当我然后单击超链接并且x-editable出现时,输入的初始值没有根据相应的<a>元素的新文本​​值更改。

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. 因此,如果初始div大小为400x400,然后将其调整为600x400,则当我单击以编辑宽度时,初始文本框值仍为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());
}

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. 现在,如果我.editable()在a元素上都正常调用.editable() ,但是问题是我丢失了所有我希望保留的x-editable的所有其他设置。 Is there any way I can do this without calling .editable() again with all of the other settings every time I resize the divs ? 每次调整div的大小时,是否可以通过其他所有设置再次调用.editable()来实现此.editable()

JSFiddle JSFiddle

You need to reload the X-editable function, but before you can du that you need to destroy it like this: 您需要重新加载X可编辑函数,但是在删除之前,您需要像这样销毁它:

$(".width-editable").editable('destroy');
$(".height-editable").editable('destroy');

I have edited your JSFiddel, please see the new one here: http://jsfiddle.net/xBB5x/9957/ 我已经编辑了您的JSFiddel,请在此处查看新的JSFiddel: http : //jsfiddle.net/xBB5x/9957/

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM