kumar
kumar

Reputation: 2944

Not working for single click..Jquery Grid

 $("#table_id").click(function(e) {
                  var row = jQuery(e.target || e.srcElement).parent();
                  $("#table_id").bind('click', loaddata);
                  name= row.attr("id");
              });

loaddata is the funcation I am calling on click on each row.

But this click event is working for double click. I mean when you double click its working fyn.

But i need it to work for single click on the row.

Is that anything I am doing wrong here?

Upvotes: 1

Views: 750

Answers (2)

elkelk
elkelk

Reputation: 1752

The JQuery click function is the same as the bind function using the 'click' parameter. The reason it works for double-click is that the initial click function fires the bind function which then allows click to fire loaddata.

Instead try passing the row and name to loaddata:

 $("#table_id").click(function(e) {
              var row = jQuery(e.target || e.srcElement).parent();
              name = row.attr("id");
              loaddata(row, name);
          });

Upvotes: 1

GordonBy
GordonBy

Reputation: 3407

change

$("#table_id").bind('click', loaddata);

to

$("#table_id").bind('click', function() {loaddata();});

Also, it looks a bit weird in the fact inside the $("table_id") click, you are binding a function to the click.

Are you meaning to do the following?

 $(row).bind('click', function() {loaddata();});

Upvotes: 2

Related Questions