3

在我的 x-editable 字段中,我有一个要根据返回值更新的文本区域。这在我使用时有效$(this).html(newVal);,如下所示

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

问题是当我第二次单击编辑字段时,输入对象(类:)内的值editable-input与发送时保持相同。 有没有办法来解决这个问题?

4

2 回答 2

6

最简单的方法:

        $('.textarea').editable({
            success: function(response, newValue) {
                    return {newValue: response.newValue};
                }
            }
        });

记得在响应内容中返回 newValue 变量:

{"newValue":"some_string_new_value"}
于 2014-07-15T08:40:29.423 回答
2

这行得通。我通过在on success回调中调用此函数来设置值

  function formatXEditable($item, $val){
    $val = $val.replace(/<br\s*\/?>/mg,"\n");
    $($item).on('shown', function(e, editable) {
      editable.input.$input.val($val);
    });
  }
于 2013-12-11T04:18:12.413 回答