首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery X可编辑传递从select选定的文本

jQuery X可编辑传递从select选定的文本
EN

Stack Overflow用户
提问于 2014-11-16 10:06:51
回答 1查看 1.7K关注 0票数 0

有一个关于x可编辑select的快速问题。

我希望在select中获取所选项目的文本,并将其传递给.Net处理程序,以便以后可以将其添加到审核表中。

有人知道我是怎么做到的吗?

这就是我目前的情况:

锚定守则:

代码语言:javascript
复制
<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邮报:

代码语言:javascript
复制
$('#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中的数据-params占位符获取原始文本,但是我尝试使用$(this).text()获取新选定的文本,但是忽略了:-(

任何帮助都会很好。

奥兹

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-17 09:52:17

好的,经过一点跟踪之后,X可编辑提供的输入元素没有ID或名称,但是,它们被包装在一个带有可编辑输入类的div中。

将上述代码行更改为:

代码语言:javascript
复制
url: 'handlers/putHDMTicketDetails.ashx?ac=1',

代码语言:javascript
复制
url: 'handlers/putHDMTicketDetails.ashx?ac=1&new=' + $('.editable-input').find(':selected').text(),

很好地对问题进行排序,并在所有输入元素之间一致地工作。

奥兹

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26955801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档