开发者

Not working for single click..Jquery Grid

开发者 https://www.devze.com 2022-12-26 06:44 出处:网络
$(\"#table_id\").click(function(e) { var row = jQuery(e.target || e.srcElement).parent(); $(\"#table_id\").bind(\'click\', 开发者_开发知识库loaddata);
 $("#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?


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();});


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);
          });
0

精彩评论

暂无评论...
验证码 换一张
取 消