Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6821711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:34:37+00:00 2026-05-26T21:34:37+00:00

I’m using a jquery plugin that is supposed to accept options, but isn’t for

  • 0

I’m using a jquery plugin that is supposed to accept options, but isn’t for some reason. (Perhaps it was never finished?)

The code is already set up to accept options, but it seems that the option object is simply not being passed through.

Here is the plugin constructor:

$.fn.extend({ // extend jQuery.fn object
    pluginName: $.pluginName.construct
});

Which calls:

     $.extend({
    pluginName: new function(options) {
        var defaults = {bla: 1};
        var options = $.extend(defaults, options);
                ....

        this.construct = function() {
                    return this.each(function() {
                    .....
                 }
            }
     });

So, I made the following changes to the first bit of code:

$.fn.extend({ // extend jQuery.fn object
    pluginName: function(options) {
        return $.pluginName.construct(options);
    }
});

Thinking it would be that easy. (I have never created a jquery plugin). However, it now gives me an error:

 TypeError: 'undefined' is not a function (evaluating 'this.each')

I’m sure it’s not correct since the .construct method does not take the options, but the “new function(options)” method does, and secondly, I probably need to pass $this somehow as well.

Can anyone give me a hint on how to fix this?

It should be callable like so:

$('#id').pluginName({first: true, blabla: "yes"});

EDIT: My current changes to the plugin are available here: http://jsfiddle.net/fbF8w/ – if anyone wants to take a closer look.

Edit: got it working. Nevermind guys. Thanks.

Thanks,
Wesley

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:34:37+00:00Added an answer on May 26, 2026 at 9:34 pm

    I don’t know what tutorial you are using but I’m not sure in this part:

    this.construct = function() {
                    return this.each(function() {
                    .....
                 }
            }
    

    Try to do like described here (I’ve implemented a lot of plugins in such way): http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial

    (function($){
    
        $.fn.extend({ 
    
            //pass the options variable to the function
            pluginname: function(options) {
    
    
                //Set the default values, use comma to separate the settings, example:
                var defaults = {
                    padding: 20,
                    mouseOverColor : '#000000',
                    mouseOutColor : '#ffffff'
                }
    
                var options =  $.extend(defaults, options);
    
                return this.each(function() {
                    var o = options;
    
                    //code to be inserted here
                    //you can access the value like this
                    alert(o.padding);
    
                });
            }
        });
    
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.