当我在我的应用程序中使用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