我使用 jquery 插件:https ://code.google.com/archive/p/jquery-in-place-editor/ 。在下一节中,我使用“JEIP”而不是全名。
我尝试通过 css 类将 JEIP 不绑定到 ID 而是绑定到许多对象。
<div class="jeip" id='key1' data-type='elephant'>Text 1</div>
<div class="jeip" id='key2' data-type='mouse'>Text 2</div>
现在我也想动态传递数据类型元素。我想出了“参数”选项来传递额外的数据。但它似乎不是动态的。
要初始化 JEIP,我使用:
$(".editInPlace").editInPlace({
url: "http://submitUrl/",
params: "datatype="+$(this).data('type'),
callback: function(){
console.log( $(this).data('type') );
},
}
但是参数是错误的。我只在接收提交操作的服务器脚本中得到 undifiend。当我使用回调函数时,我可以获得带有正确数据的控制台输出。如何将数据元素传递给服务器?
感谢帮助。