0
我有一个X-editable元素可以从data-pk属性中获取字段。X可编辑的动态数据-pk值
<button class='edit' data-pk='field|value'>My Button</button>
我正在动态更新此按钮,并使用另一个下拉菜单。因此,数据PK更新,无论我从下拉列表中选择什么字段。
DOM按预期更新。
但是,当X-editable触发请求时,其旧的第一次启动的数据-pk值。 在发送到服务器之前,我怎样才能读取当前值?
X编辑代码...
$('.edit').editable({
url:'user/edit',
// Need something here to retrieve the real current value of data-pk.
// not initiated value
success:function(response,value){
// Do success stuff.
}
});
我试过......
$('.edit').editable({
url:'user/edit',
pk:$(this).attr('data-pk'),
success:function(response,value){
}
});
但没有工作,也试过......
$('.edit').editable({
url:'user/edit',
params:function(params){
var data={};
// Need to get this instance, and fetch the current data-pk
// So I can set it in this data, but I have no idea how to get it.
// params.pk just gives me the old value. I need to get the new value
return data;
},
success:function(response,value){
// Do success stuff.
}
});
我在同一条船上。你有没有得到解决方案? – ToddT
是的,我找到了解决方案....像这样 params:function(params){ params.pk = $(this).attr('data-pk'); return params; }, – KyleK