[jQuery] jQuery unbind not working in greasemonkey ... simple test case included

[jQuery] jQuery unbind not working in greasemonkey ... simple test case included


Hi all,
Thanks for any help with this one. I've developed a very simple test
case to demonstrate the behavior.
First I created unbind.html (below) that includes jQuery, binds, then
immediately unbinds all anchor tags to tmpfunc that would print 'hello
world' on the firebug console. It works as expected.
On unbind.html, I include a link to unbind.user.js (below) that does
exactly what the script on unbind.html does. That is it binds and then
immediately unbinds all anchor tags to tmpfunc.
Expected behavior when running the GM script: nothing. It should bind,
then immediately unbind the same tmpfunc.
What actually happens, it binds, and I see 'hello world' on the
console. It DOES NOT unbind.
Can anyone help me with this test case or explain what's going on?
I'm using FF 3 and GM 0.8.
(You can modify unbind.html once you have the GM scrip loaded &
comment out its jQuery script and head script to make sure that there
is no conflict. You see the same behavior.)
Thanks,
Keith
ps. I realize this may be a GM isse and not a jQuery issue, but any
insight is appreciated.
unbind.html src:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Testing unbind</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/
jquery.min.js">
</script>
<script>
$(document).ready(function (){
var CL = console.log
CL('running on '+location.href+' without GM');
var tmpfunc = function () {
CL('hello world');
return false;
}
$('a').bind('click', tmpfunc);
$('a').unbind('click', tmpfunc);
});
</script>
</head>
<body>
<a href="./unbind.user.js">test</>
</body>
</html>
unbind.user.js src:
// ==UserScript==
// @name unbind
// @namespace myname
// @description testing jQuery unbind in GM
// @include http://*/unbind.html
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js
// ==/UserScript==
$(document).ready(function (){
var CL = unsafeWindow.console.log
CL('GM running on '+location.href);
var tmpfunc = function () {
CL('hello world');
return false;
}
$('a').bind('click', tmpfunc);
$('a').unbind('click', tmpfunc);
});
--
Keith Bentrup
http://www.keithbentrup.com
http://www.c21gt.com





































































    • Topic Participants

    • keith