In its previous code there was this error, in addition to the wrong use of this within the closure, as indicated in EDIT below.
Using this within the plugin method
In this case, the this
is already jQuery’s own object.
I mean, instead of doing this $(this)
, use only this
.
this
in this case is the object used to call the method:
$("#xpto").dumb( ... );
In the plugin, this
refers to the actual $("#xpto")
.
Reference:
http://learn.jquery.com/plugins/basic-plugin-creation/
EDIT:
Problem with this na closure
In javascript, the object this
is directly linked to the current running method. So you will need to store the jquery object, in a variable, before using it within a closure:
(function ($) {
$.fn.dumb = function () {
var _this = this;
$(document).ready(function () {
var video = _this;
video.contextmenu(function () {
return false;
});
});
};
})(jQuery);
Please place all relevant code at the beginning of the question. Note that the code you have is missing the closure of a function
};
– Sergio