快速提问x-Editable select's。
我想在选择中获取所选项目的文本并将其传递给.Net处理程序,以便稍后将其添加到审计表中。
有没有人有任何想法我怎么能这样做?
这就是我目前的情况:
锚码:
<a class='editable' data-type='select' data-name='statusid' data-pk='1027' data-params='{"original": "In Progress"}' data-value='2' data-source='handlers/getHDMLists.ashx?l=1' id='status'>In Progress</a>
和jQuery Post:
$('#status').editable({
showbuttons: true,
url: function (params) {
return $.ajax({
type: 'POST',
url: 'handlers/putHDMTicketDetails.ashx?ac=1',
data: params,
params: '{"new": "' + $(this).text() + '"}' ,
async: true,
cache: false,
timeout: 10000,
success: function (response) {
if (response != null) {
if (response.msg == "SUCCESS") {
$.gritter.add({
title: 'Update Successful',
text: 'Support ticket details update was successful.',
class_name: 'gritter-success gritter-center gritter-light'
});
} else {
$.gritter.add({
title: 'Something went wrong!',
text: 'There seems to have been an error with your requested update, please try again and if you continue to receive this message please contect your site administrator.',
class_name: 'gritter-error gritter-center'
});
}
} else {
$.gritter.add({
title: 'Something went wrong!',
text: 'There seems to have been an error with your requested update, please try again and if you continue to receive this message please contect your site administrator.',
class_name: 'gritter-error gritter-center'
});
}
},
error: function () {
$.gritter.add({
title: 'Something went wrong!',
text: 'There seems to have been an error with your requested update, please try again and if you continue to receive this message please contect your site administrator.',
class_name: 'gritter-error gritter-center'
});
}
});
}
});
正如您所看到的,我可以通过使用anochor中的data-params占位符来获取原始文本,但我尝试使用$(this).text()来获取新选择的文本,但它被忽略:-(
任何帮助都会很棒。
盎司
答案 0 :(得分:0)
好的,所以经过一些追踪后发现,X-editable提供的输入元素没有ID或名称可用,但是,它们被包含在一个带有可编辑输入类的div中。
更改以上代码行:
url: 'handlers/putHDMTicketDetails.ashx?ac=1',
到
url: 'handlers/putHDMTicketDetails.ashx?ac=1&new=' + $('.editable-input').find(':selected').text(),
可以很好地对问题进行排序,并且可以在所有输入元素中保持一致。
盎司