jquery-boilerplate / jquery-patterns

A variety of jQuery plugin patterns for jump starting your plugin development
1.59k stars 242 forks source link

Basic pattern breaks chainability #18

Closed yckart closed 11 years ago

yckart commented 11 years ago

Is it a good practice to break the second plugin instance if we call it like this?

$(selector).defaultPluginName({
    start: 13,
    end: 37
}).defaultPluginName({
    start: 37,
    end: 42
});

It will not work since we allow the plugin only to be instantiated once per element. But to remove the if statement in our plugin definition is even not the best idea, or?

addyosmani commented 11 years ago

Let's explore if we can come up with a cleaner way of handling this. @zenorocha what do you think about the lightweight start in this repo? Is it different enough from the jQuery boilerplate for us to continue keeping in place or should we try to refactor it further?

zenorocha commented 11 years ago

They are very similar, so I think it's better to refactor or remove the lightweight start from here and maintain the other one. Since you already made a reference for jQuery Boilerplate in README I think that will not be a problem.

addyosmani commented 11 years ago

I agree with removing it. Do you think it's worth documenting the jQuery Boilerplate better in the chapter in my book as a replacement to the lightweight start too? It might help get a few more folks looking at it as well.

zenorocha commented 11 years ago

Yeah, that would be nice!

addyosmani commented 11 years ago

@zenorocha how should we do this? submodule the main boilerplate or just link to it from the readme?

zenorocha commented 11 years ago

Just link, since the boilerplate repository has a different structure of patterns repository.

yckart commented 11 years ago

Yap, i agree with @zenorocha, providing just a link in the README seems to be the most logical way.