Please take a look at the following:
jQuery.fn.jqPos = function(target, settings) {
settings = jQuery.extend({
offset: [ 0, 0 ]
}, settings);
return this.each(function() {
magic($(this), target, settings);
$(window).resize(function(){
magic($(this), target, settings);
});
});
function magic(self, target, settings) {
// Here I position self close to target
}
};
This works perfectly when I first initialize the plugin, like $('div#one').jqPos($('div#two'));
and the magic method runs as it should. But at the event window.resize
nothing happens at all (I want it to run the same method with the same settings and parameters)!
How come? And how to overcome?
EDIT: In the magic-method (at window.resize), the arguments are all undefined
.