日期:2014-05-16  浏览次数:20442 次

原型里面方法形参传构造函数的属性,但值没变??求解!

    function Plugin( element, options ) {
        this.options = $.extend( {}, defaults, options );
        this.element = $(element);
        this._defaults = defaults;
        this._name = pluginName;
       // this.tagType = ':checkbox', ':radio','select';
        this.stackiSelect = $();
        this.stackiCheckbox = $();
        this.stackiRadio = $();
        this.init();
    }

    Plugin.prototype = {
        init: function() {
            var fm = this;
            this.identify(this.element,'select',this.stackiSelect);
            console.log(this.stackiSelect);//undefined ??
            this.stackiSelect.each(function(index, domEle) {
               //.........  
            });
        },
        /*identify the tagType ,and take the tag for transform to the stack */
        identify: function(object,tagType,stack) {
            object.each(function() {
              var self = $(this);
              stack = self.is(tagType) ? stack.add(self) : stack.add(self.find(tagType));//identify 
            });
        }
    }


(写成插件的...)从选择器选择的中筛出checkbox radio select ,然后美化下..定义了三个容器stackiSelect 
stackiCheckbox stackiRadio 作为构造函数的属性,然后我想重用原型里的写的identify()但是调用后没用为空.
如果这样是可以的: