infinite-scroll学习(三)

$.infinitescroll = function infscr(options, callback, element) {
    this.element = $(element);

    // Flag the object in the event of a failed creation
    if (!this._create(options, callback)) {
        this.failed = true;
    }
};

上面这段代码先从下面这部分开始分析

function infscr(options, callback, element) {
    this.element = $(element);

    // Flag the object in the event of a failed creation
    if (!this._create(options, callback)) {
        this.failed = true;
    }
};

 

这是一个类定义的语句,这个类的构造函数有三个形参"options, callback, element"。
此类有两个属性--"element"和"failed"。"element"使用的是"$(element)"对象。注解:$(element)中的$()是jQuery中的方法,用途是取得对应的对象。
构造函数中会调用原型中的_create方法,来进行创建,如果创建失败,会对属性"failed"赋值成false。

前面"$.infinitescroll = function infscr"是将对象的定义赋值给"$.infinitescroll"。

你可能感兴趣的:(JavaScript,js,Infinite-Scroll)