Skip to main content

Bug Tracker

Side navigation

#1034 closed bug (duplicate)

Opened March 09, 2007 01:58PM UTC

Closed March 15, 2007 04:34PM UTC

Problem with .bind () method

Reported by: CobaltWave Owned by:
Priority: major Milestone: 1.1.3
Component: event Version: 1.1.2
Keywords: bind, event handler, pass data object Cc:
Blocked by: Blocking:


The .bind () method is not behaving like I would expect it to. I have two lists in HTML:

<ol id="greenList">








<ol id="blueList">


I have the following event handler, that moves clicked elements to the other list:

function moveItem (e) {

var targetList = "ol#" +;

$( ().appendTo (targetList);

$( ();


I would like to bind the event handler to each <ol> element like so:

$("ol#greenList").bind ("click", {target: "blueList"}, moveItem);

$("ol#blueList").bind ("click", {target: "greenList"}, moveItem);

However this doesn't work. Once the .bind () for blueList is performed, the for the event handler in the greenList is "greenList" and it should have remained "blueList".

I had to rewrite my event handler like so:

function moveItem (e) {

var targetList = "ol#" + [$(this).attr("id")];

$( ().appendTo (targetList);

$( ();


and bind in this fashion for the code to work:

$("ol#greenList").bind ("click", {greenList: "blueList", blueList: "greenList"}, moveItem);

$("ol#blueList").bind ("click", {greenList: "blueList", blueList: "greenList"}, moveItem);

This doesn't seem right to me. Is there a bug with passing a "data" object to the bind method?

Best regards,


Attachments (0)
Change History (1)

Changed March 15, 2007 04:34PM UTC by john comment:1

resolution: → duplicate
status: newclosed

This is a duplicate of bug #935.