Managing this scope in javascript
<p>I am trying to get this function to get the correct scope for its "this" operator, but no luck. Inside the <code>AssetName = function(options){</code> code block, I want the "this" to point to the class <code>AssetName</code>. What is it that I am missing? The scope of <code>this</code> right from the beginning is <code>window</code>.</p>

<pre><code>Assetname: function(options){

    var Base = WM.Utility.GenericFilter()
        options = options;

        if (typeof Object.create !== "function") { // For older browsers that don't support object.create
            Object.create = function (o) {
                function F() {}
                F.prototype = o;
                return new F();
            };
        }       

        var AssetName = {};
        AssetName = function(options){
            return function(){
                var self = this;

                debugger;
                // Call the super constructor.
                Base.call(this, options);

                this.$mod.on('change', '#asset-name-quick-search', self,  this.search);
                this.$mod.on('click', '.close', self,  this.remove);

                this.initTypeAhead();
                this.$selectionList = this.$mod.find("#asset-name-selection-list");

                this.assetListItems = [];

                return this;    
            }(options, AssetName);

        }

        // The AssetName class extends the base GenericFilter class.
        AssetName.prototype = Object.create(Base.prototype);

        AssetName.prototype.initTypeAhead = function(){
            var options = {};
            options.source = _.pluck(this.collection, 'asset_name');
            options.items = 8;
            this.$mod.find('#asset-name-quick-search').typeahead(options);    
        };

        AssetName(options);
        return AssetName;
},
</code></pre>
