右键单击弹出菜单慢

时间:2013-04-12 06:18:57

标签: javascript jquery dom jquery-selectors dom-traversal

我在KendoUI Grid上实现了右键单击弹出菜单。

问题是,它是慢的。

右键单击脚本需要获取单击行的id。我这样做:

salesGrid.on('mouseup', '[role="row"]', function(e){
  button = e.which ;
  if(button == 3)
  {
    $(this).bind("contextmenu",function(e){
      return false
    });

    var id = null ;
    id = $('td', this).find('.id-span').data('id') // ~500ms

我也尝试过:

id = $(this).children('td').children('.id-span').data('id') ;

id = $('td:first span', this).data('id') ;

所有这些都需要大约500毫秒才能执行,这在用户体验方面太长了。

这是它正在遍历的表格:

<tr data-uid="16e14dc2-a2fa-4979-a1ff-cd5113223aa6" role="row">
    <td role="gridcell"><span class="id-span" data-id="1">A</span></td>
    <td role="gridcell">3</td>
    <td role="gridcell">Lenze</td>
    <td role="gridcell"><span class="popoverintel" data-trigger="hover" data-placement="bottom" data-part-id="1">33.8202-E</span></td>
    <td role="gridcell">Supply</td>
    <td role="gridcell">New</td>
    <td role="gridcell">3</td>
    <td role="gridcell">€</td>
    <td role="gridcell">575.00</td>
    <td role="gridcell">1725.00</td>
</tr>

有没有办法让它更快?

1 个答案:

答案 0 :(得分:0)

尝试按'[role="row"]'

更改选择器'tr[role="row"]'
相关问题