Here is small plugin to show where I am having an issue. Obviously this just prints the current selector to the console.
(function ($) {
$.fn.testSelector = function () {
console.log(this.selector);
}
}(jQuery));
Everything works how I would expect it to in the following example.
$('#myid > p').mouseup(function(){
$('#myid').testSelector();
}); // prints #myid
This prints #myid in console just like it is suppose to.
However if I use the $(this) it returns an empty string.
$('#myid > p').mouseup(function(){
$(this).testSelector();
}); // prints an empty string
This make sense, as 'this' is referring to the selected DOM object, though it is very inconvenient. The plug-in I have been working on requires having access to the selector string in both scenarios.
I am wonder if any body know of a way of consistently passing or storing the selector string in a way that can be accessed from $(this)?