Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 基于返回值更新x-可编辑输入字段_Javascript_X Editable - Fatal编程技术网

Javascript 基于返回值更新x-可编辑输入字段

Javascript 基于返回值更新x-可编辑输入字段,javascript,x-editable,Javascript,X Editable,在我的x-editable字段中,我有一个要根据返回值更新的文本区域。当我使用$(This.html(newVal)时,它就可以工作了如下所示 success: function(response, newValue) { newVal=unescape(JSON.parse(response).VALUE) $(this).html(newVal); } 问题是,当我第二次单击编辑字段时,输入对象(类:可编辑输入)内的值与发送时的值保持不变。有办法解决此问题吗?这很有效。我通过在

在我的x-editable字段中,我有一个要根据返回值更新的文本区域。当我使用
$(This.html(newVal)时,它就可以工作了如下所示

success: function(response, newValue) {
  newVal=unescape(JSON.parse(response).VALUE)
  $(this).html(newVal);
}  

问题是,当我第二次单击编辑字段时,输入对象(类:
可编辑输入
)内的值与发送时的值保持不变。
有办法解决此问题吗?

这很有效。我通过在
on success
回调中调用此函数来设置值

  function formatXEditable($item, $val){
    $val = $val.replace(/<br\s*\/?>/mg,"\n");
    $($item).on('shown', function(e, editable) {
      editable.input.$input.val($val);
    });
  }
函数formatXEditable($item,$val){
$val=$val.replace(//mg,“\n”);
$($项).on('显示')函数(e,可编辑){
可编辑的.input.$input.val($val);
});
}
最简单的方法:

        $('.textarea').editable({
            success: function(response, newValue) {
                    return {newValue: response.newValue};
                }
            }
        });
请记住在响应内容中返回newValue变量:

{"newValue":"some_string_new_value"}

看看我上面的答案,我有同样的问题,但我想通过编程更改字段的值。在单击编辑值之前,所有内容都是这样的;老的出现了。