Changing the value of x-editable

拥有回忆 提交于 2019-12-25 03:57:09

问题


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.

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());
}

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 ?

JSFiddle


回答1:


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');

I have edited your JSFiddel, please see the new one here: http://jsfiddle.net/xBB5x/9957/

Hope it helps!



来源:https://stackoverflow.com/questions/33893140/changing-the-value-of-x-editable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!