[SOLVED] When creating a plugin, how do you make it so you can call it with more than one config
I'm currently creating a plugin that you call on elements and it modifies the elements in some way. What I'm trying to do is make it so that you can call it more than once on different elements, each with their own config and options.
So far, my plugin works great on one element, but the next time I call it on an element, both of the elements use the second one's config.
I'm wondering what exactly in the plugin allows this to happen. Here's some of the code:
- (function($) {
- _jCInit = true;
- $.jClone = {
- defaults: {
- <defaults are in here>
- }
- }
- $.fn.extend({
- jClone:function(config, options){
- var config = $.extend({}, $.jClone.defaults, config);
-
- <main code in here>
- }
- });
- })(jQuery);
Did I write all of this right or did I miss some stuff?
I followed several tutorials and all of them seemed to have different ways of setting up the plugin.
One thing that I thought might have something to do with it was this:
- return this.each(function() {
- });
I'm still new to jQuery, so go easy on me if my code is completely fudged up.