Hello,
I am creating a plugin and it cannot access $(this). A simple overview of my plugin is
(function($){
$.fn.myPlugin= function(options, callback) {
return this.each(function(){
$(this).click(function(){
// some plugin works ..
callback();
});
});
};
})(jQuery);
Then i attached my plugin to a element like
$('p').myPlugin({
// Some options
}, function(){
alert('first test');
alert($(this).text());
});
Here when the element p is clicked, i get the first alert, but i didn't get the 2nd alert.
The callback function is called, but unable to access this
.
Is there any problem with the defining or with code ? any alternative suggestion will also be helpful