Maybe because you are return reference to the function not a jQuery object:

 > return this;

Read this post:
http://jquery-howto.blogspot.com/2008/12/how-to-create-jquery-plugin-extending.html

It explains why you need to return jQuery object.



On Sat, Feb 7, 2009 at 1:28 PM, ShurikAg <shuri...@gmail.com> wrote:
>
> Question related to the same plugin:
>
> Plugin code:
> jQ.fn.table = function(options, titles, data){
>                if(jQ(this).length == 0){
>                        //try to find at least one element
>                        $.log("Matching element "+jQ(this).selector+" was not 
> found!")
>                        return null;
>                }
>                //validate that this element is unique i=on hte page
>                if(jQ(this).length > 1){
>                        $.log("The element's selector must be unique on the 
> page!");
>                        return null;
>                }
>                //check if the elemment is a table
>                //alert(jQ(this).selector);
>                if(!jQ(this).is('table')){
>                        $.log("The element must be valid table element!");
>                        return null;
>                }
>                /**
>                 * Save the selector for further
>                 */
>                Selector = jQ(this).selector;
>
>                //extend defaults
>                Options = jQ.extend({}, Defaults, options);
>                //init additional data
>
>                //init UI
>                jQ.fn.table.initUI();
>
>                return this;
>        };
>
> and I'm running it as:
> var $table = $('table');
> $table.table();
>
> and I'm always getting: "The element must be valid table element!"
>
> I've tried to trace what the selector is; and once it is "table" but
> the second time (in he same run) is null. Why there are two entries to
> this function anyways? I have only one table on the page.

Reply via email to