jQuery X-editable 从选择中传递选定的文本
jQuery X-editable pass selected text from select
有一个关于x-Editable select的快速问题。
我想在选择中获取所选项目的文本并将其传递给 .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 中使用数据参数占位符来获取原始文本,但我试图使用 $(this).text() 获取新选择的文本,但它被忽略了:-(
任何帮助都会很棒。
奥兹
好的,
所以经过一些跟踪,事实证明X-editable提供的输入元素没有可用的ID或名称,但是,它们被包装在一个带有可编辑输入类的div中。
将上面的代码行从:
url: 'handlers/putHDMTicketDetails.ashx?ac=1',
自
url: 'handlers/putHDMTicketDetails.ashx?ac=1&new=' + $('.editable-input').find(':selected').text(),
很好地对问题进行排序,并在所有输入元素中保持一致。
奥兹
相关文章:
- 如何使用jquery在填充自动完成的值后使文本框只读
- 使用Clipboard.js复制span文本
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 用程序搜索JQuery数据表中的文本
- jQuery匹配JSON对象的部分文本
- onkeyup无法动态创建多个文本区域
- 如何在下面的ES6循环中获得前面的文本
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 让文本输入幻灯片显示输入时的新文本输入?然后向后滑动
- 借助asp.net验证或java脚本对多个文本进行验证
- 无法在ajaxStart中更改跨度文本
- 高亮显示时编辑文本大小和颜色
- jquery中的文本框验证
- Javascript,有没有一种方法可以将数组写成没有逗号或空格的单个文本字符串
- Sails.js:同时发布文本输入和一个文件
- 当鼠标悬停在文本中的单词上时显示警报
- 是否有任何方法可以使用jQuery替换在数组中定义值的文本
- 将纯文本URL转换为可单击链接
- jQuery X-editable 从选择中传递选定的文本
- 可编辑元素,覆盖不起作用的原始文本(x-Editable)