我有一个这个 jsfiddle
它使用了toggle event - 不要与toggle 混淆 - jQuery 版本设置为EDGE
它突然停止工作并删除了我想要的单元格作为触发器,因为它明显会恢复到toggle。
我找不到任何弃用标签或类似的东西
http://api.jquery.com/category/deprecated/ 返回404
如果我添加Migrate模块,我的jsFiddle 然后就可以工作了,并且在控制台中看到警告(由Frédéric Hamidi发布的https://github.com/jquery/jquery-migrate/blob/master/warnings.md详细说明)
我看到Deprecate fn toggle 和issue 24 和 Ticket #11786 ,但不在我期望看到它的地方。
我错过了什么,我在哪里可以找到它的替代品和文档?
注意:我理解弃用的原因,我只是找不到官方的弃用文档
$('#tbl .xx').toggle(
function() {
$(this).siblings().each(function(){
var t = $(this).text();
$(this).html($('<input />',{'value' : t}));
});
},
function() {
$(this).siblings().each(function(){
var inp = $(this).find('input');
if (inp.length){
$(this).text(inp.val());
}
});
}
);
MIGRATE 中的代码:
jQuery.fn.toggle = function( fn, fn2 ) {
// Don't mess with animation or css toggles
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
return oldToggle.apply( this, arguments );
}
migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
// Save reference to arguments for access in closure
var args = arguments,
guid = fn.guid || jQuery.guid++,
i = 0,
toggler = function( event ) {
// Figure out which function to execute
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
// Make sure that clicks stop
event.preventDefault();
// and execute the function
return args[ lastToggle ].apply( this, arguments ) || false;
};
// link all the functions, so any of them can unbind this click handler
toggler.guid = guid;
while ( i < args.length ) {
args[ i++ ].guid = guid;
}
return this.click( toggler );
};
更新 我已经要求他们将代码保留为fn.toggler,这样就是重命名而不是删除操作。