Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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来创建可以通过ajax调用就地编辑的链接 我的页面上所有可编辑的内容都是使用类editable创建的,并使用data-*参数将值传递给x-editable。总的来说,这是可行的,因为更新提交得很好 但是,在下面的示例中,data success函数从不调用-在本例中,我从未看到控制台日志 <a href="#" class="editable" data-type="select" data-send="always" data-source='{"

我正在使用X-editable来创建可以通过ajax调用就地编辑的链接

我的页面上所有可编辑的内容都是使用类editable创建的,并使用data-*参数将值传递给x-editable。总的来说,这是可行的,因为更新提交得很好

但是,在下面的示例中,data success函数从不调用-在本例中,我从未看到控制台日志

<a href="#"  
class="editable" 
data-type="select" 
data-send="always" 
data-source='{"Windows 2000":"Windows 2000","Windows Server 2003":"Windows Server 2003","Windows Server 2008":"Windows Server 2008","Windows Server 2008 R2":"Windows Server 2008 R2","Windows Server 2012":"Windows Server 2012","Windows Server 2012 R2":"Windows Server 2012 R2","Other":"Other"}' data-name="Value"  
data-pk="1155"
data-display="function (value, response) { return false;}"
data-success="function (response, newValue) { console.log('success');}"
data-url="/attribute/updateField"
data-title="Title info">Windows Server 2008</a>

我问过X-editable的程序员,因为我在做同样的事情,他回答说不可能。他的回答是:

我认为这是不可能的,因为数据属性是经过解析的,但不能作为javascript进行评估

另外,我认为更好的方法是将js逻辑存储在js文件中,而不是存储在html属性中


我问过X-editable的程序员,因为我在尝试同样的事情,他回答说这是不可能的。他的回答是:

我认为这是不可能的,因为数据属性是经过解析的,但不能作为javascript进行评估

另外,我认为更好的方法是将js逻辑存储在js文件中,而不是存储在html属性中


我找到的最干净的解决方案是:

HTML:

<a href="#"  
class="editable" 
data-type="select" 
data-send="always" 
data-source='{"Windows 2000":"Windows 2000","Windows Server 2003":"Windows Server 2003","Windows Server 2008":"Windows Server 2008","Windows Server 2008 R2":"Windows Server 2008 R2","Windows Server 2012":"Windows Server 2012","Windows Server 2012 R2":"Windows Server 2012 R2","Other":"Other"}' data-name="Value"  
data-pk="1155"
data-eval-display="console.log('display', response, newValue);"
data-eval-success="console.log('success', response, newValue);"
data-url="/attribute/updateField"
data-title="Title info">Windows Server 2008</a>

我找到的最干净的解决方案是:

HTML:

<a href="#"  
class="editable" 
data-type="select" 
data-send="always" 
data-source='{"Windows 2000":"Windows 2000","Windows Server 2003":"Windows Server 2003","Windows Server 2008":"Windows Server 2008","Windows Server 2008 R2":"Windows Server 2008 R2","Windows Server 2012":"Windows Server 2012","Windows Server 2012 R2":"Windows Server 2012 R2","Other":"Other"}' data-name="Value"  
data-pk="1155"
data-eval-display="console.log('display', response, newValue);"
data-eval-success="console.log('success', response, newValue);"
data-url="/attribute/updateField"
data-title="Title info">Windows Server 2008</a>