I often use links with href='#'
when calling ajax resources.
I noticed that IE makes an audible "click" when clicking these links.
Here's a workaround:
$("#element")
.click(function(){return false;})
.bind("click", function(){ alert(this); });
HOWEVER, when I try to encapsulate this functionality in a jQuery plugin, I'm not successfully returning the "clicked" element.
For instance, if I use the approach above I'll get the actual A element that was clicked.
But if I write a plugin like this:
(function($){
$.fn.clickless = function(fnCallback) {
return this
.click(function(){return false;})
.bind("click", function(){
fnCallback.call();
});
}
})(jQuery);
And then call
$("#element").clickless(function(){
alert(this);
});
I'll get the Window
object, which doesn't help when I'm trying to find the actual A tag.
Maybe I'm just writing the plugin incorrectly -- any ideas?
Thanks so much,
Michael