Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
升级到JQuery-1.7.1后将.live()转换为.on()无法修复此函数_Jquery - Fatal编程技术网

升级到JQuery-1.7.1后将.live()转换为.on()无法修复此函数

升级到JQuery-1.7.1后将.live()转换为.on()无法修复此函数,jquery,Jquery,当我在应用程序中使用JQuery-1.6.1时,我有以下代码行: $('li.step .step_type.VerifyTableContentsStep input[name*=element_name]').live('autocompletechange', buildTableContents); 在我升级到JQuery-1.7.1之后,该行停止工作。我在文档中看到.live已被弃用,改为使用.on。我试过了,根据文档,更改了行,现在是这样的: $(document).on('aut

当我在应用程序中使用JQuery-1.6.1时,我有以下代码行:

$('li.step .step_type.VerifyTableContentsStep input[name*=element_name]').live('autocompletechange', buildTableContents);
在我升级到JQuery-1.7.1之后,该行停止工作。我在文档中看到.live已被弃用,改为使用.on。我试过了,根据文档,更改了行,现在是这样的:

$(document).on('autocompletechange', 'li.step .step_type.VerifyTableContentsStep input[name*=element_name]', buildTableContents);
但它仍然不起作用。有人有什么想法吗?我严格遵守文件规定。谢谢

更新:这是我的.haml代码:

.table_contents_container
  = select_tag :add_column, options_for_select(table_contents.headers_without_data.unshift(['hidden columns...'])), :class => 'add_column_selector'

  %table

    %tr
      %th.action_column
        = link_to '', '#', :class => 'sub_item_action add_column', :tabindex => 999
      - table_contents.rows.first.all_cells.each do |cells|
        %th.content_column{ :class => "#{'no_data' if cells.no_data?}", 'data-column-id' => cells.id }
          = link_to '', '#', :class => 'sub_item_action inline_delete', :tabindex => 999
          %span= cells.name
      %th  

    - table_contents.rows.each do |row|
      %tr

        %td.action_column
          - if input_elements 
            = link_to '', '#', :class => 'sub_item_action inline_add', :tabindex => 999
            = link_to '', '#', :class => 'sub_item_action inline_delete', :tabindex => 999
          - else
             

        - row.all_cells.each do |cell|
          %td.content_column{ :class => "#{'no_data' if cell.no_data?}", 'data-column-id' => cell.id }
            - if input_elements 
              = text_field_tag "step[table_contents][][#{cell.id}]", cell.value, :onfocus =>"if(this.value=='Table Value...') this.value='';",:placeholder => 'Table Value...', :onblur => "if(this.value=='') this.value='Table Value...'", :disabled => cell.no_data?
            - else
              = h ParsedLine.new(cell.value).result

        %td  

.live在1.7.1中仍然有效。如果线路停止工作,则错误在其他地方。也许您必须更改选择器以输入[name*=element\u name]引用值。或者事件处理程序中可能存在问题。查看控制台中的错误并设置断点,逐步检查代码并进行一些基本调试。您是否尝试过使用$body.on而不是$document.on?您是否可以提供JS fiddle?我在1.71中也遇到过这个问题,尝试升级到1.8,我做到了,并且它修复了我的问题。on问题不是jquery UI的AutoCompleteTechange部分吗?你升级到兼容版本了吗?