0

i'm using the jquery boilerplate () and am having trouble accessing my options thru my differents methods.

For example

Plugin.prototype = {
    init: function()
    {
        console.log(this.options); // This output my options

        $(this.element).on('mouseenter', this.enter);
        $(this.element).on('mouseleave', this.leave);
        $(this.element).on('click', this.click);
    },
    enter: function(e)
    {
        console.log(this.options); // This output 'undefined'
    }
}

I'm trying to have access to my options in my enter method but without success.

Can someone help me figured out why?

Thanks

Steve
  • 309
  • 3
  • 17

1 Answers1

2

this in the handler is the element you clicked on.

If you want to preserve your original this, call jQuery.proxy.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Could someone give an example of how to use JQuery Proxy within the Boilerplate. I've consulted the JQuery docs but having trouble applying it to this pattern. Thanks – James Howell Jan 06 '14 at 19:57
  • @JamesHowell: What don't you understand? – SLaks Jan 06 '14 at 22:34