Passing value from one callback to another callback
<p>I created the following plugin that mostly works.  It takes xeditable, but allows for jQueryUI's autocomplete to select the value.  It mostly works, however, I am struggling on how to pass the returned <code>id</code> from jQueryUI Autocomplete to the success callback.</p>

<p>How do I pass a value from the jQueryUI autocomplete select callback to the xeditable success callback?</p>

<p>EDIT.  I got it working, but think it is a bit of a kludge.  What is the proper way to do so?</p>

<p>EDIT #2.  See <a href="https://jsfiddle.net/fndnu5m0/5/" rel="nofollow">https://jsfiddle.net/fndnu5m0/5/</a> for a demo.</p>

<pre><code>$('#targetID').xeditableAutoSource({
    source: 'getSource.php',
    success: function(response, newValue) {
        console.log($(this).data('uid')); //This is the value I want!
    }
});

(function($){

    var defaults = {
        source: [],     //Replace with URL
        placement: 'right',
        title: 'XEditable Title',
        success: function(response, newValue) {}    //id will be $(this).data('uid')
    };

    var methods = {
        init : function (options) {
            var settings = $.extend({},defaults, options  || {});

            this.each(function () {

                var $this=$(this).editable({
                    //send:'never',
                    placement:settings.placement,
                    title:settings.title,
                    success: settings.success
                })
                .on('shown', function(e, editable) {
                    var $input=editable.input.$input.val('');
                    var $button=$input.parent().next().find('button.editable-submit').css('opacity', 0.3)
                    .bind('click.prevent', function() {return false;});
                    $input.focus(function() {
                        $button.css('opacity', 0.3).bind('click.prevent', function() {return false;});
                    })
                    .autocomplete({
                        source: settings.source,
                        select: function(e, ui) {
                            $input.blur();
                            $button.css('opacity', 1).unbind('click.prevent');
                            $this.data('uid',ui.item.id);  //This is the value I need in the success callback!
                        }
                    })
                    .autocomplete('widget').click(function() {return false;});
                });

            })
        },
        destroy : function () {
            return this.each(function () {
                return this.each(function () {});
            });
        }
    };

    $.fn.xeditableAutoSource = function(method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || ! method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' +  method + ' does not exist on jQuery.xeditableAutoSource');
        }    
    };
    }(jQuery));
</code></pre>