Grow your CSS skills. Land your dream job.

Problem with jQuery plugin defualt options

  • # January 31, 2013 at 8:59 am

    I’m using the jQuery plugin template from [CSS-Tricks](http://css-tricks.com/snippets/jquery/jquery-plugin-template/ “CSS-Tricks”), but I’m having a problem with the default options.

    (function ($) {
    $.lilRWDMenu = function (el, options) {
    var base = this;
    base.$el = $(el);
    base.el = el;
    base.$el.data(“lilRWDMenu”, base);
    $.lilRWDMenu.defaultOptions = {
    mainMenuClass: ‘main-menu’,
    rwdMenuClass: ‘rwd-mobile-menu’
    };
    base.init = function () {
    base.options = $.extend({}, $.lilRWDMenu.defaultOptions, options);
    };
    base.init();
    };
    $.fn.lilRWDMenu = function (options) {
    return this.each(function () {

    var mainMenuObj = options.mainMenuClass,
    rwdmenuObj = options.rwdMenuClass;
    console.log(mainMenuObj );
    console.log(rwdmenuObj);
    });
    };
    })(jQuery);

    For some reason the default options are coming back as ‘undefined’.

    I can’t figure out why it’s not working, so if anyone can check my code for me that’ll be great.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".