Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQueryUI小部件返回jQuery包装的对象而不是值_Jquery_Jquery Ui - Fatal编程技术网

jQueryUI小部件返回jQuery包装的对象而不是值

jQueryUI小部件返回jQuery包装的对象而不是值,jquery,jquery-ui,Jquery,Jquery Ui,我有一个jQuery UI自定义小部件: $.widget('ui.objectpicker', { _init: function() { this.memberList = [/* ... */]; // ... } // ... getMemberList: function() { // this correctly logs the value I wish to return cons

我有一个jQuery UI自定义小部件:

$.widget('ui.objectpicker', {
    _init: function() {
        this.memberList = [/* ... */];
        // ...
    }

    // ...

    getMemberList: function() {
        // this correctly logs the value I wish to return
        console.log(this.memberList);
        return this.memberList;
    }
}
但是当我使用上述代码时,它返回jQuery包装的对象,而不是成员列表():


如何返回
this.memberList
而不是
$(“#我的项目”)

我的问题似乎是我的jQuery/jQuery UI的过时版本。我正在运行jQuery UI 1.7,而提供此功能的小部件工厂直到1.8(thnx到.

您需要查看$.fn.widget的实现。它似乎为用户定义的方法添加了一个包装器。因此您的返回值将被忽略。我认为您需要更改$.fn.widget的原型
$('#my-item').objectpicker('getMemberList');
// logs 'this.memberList', but returns the $('#my-item') object