问题描述
使用 toggle事件-不与切换-jQuery版本设置为 EDGE
which uses toggle event - not to be confued with toggle - jQuery version set to EDGE
由于突然恢复为 toggle .
我找不到任何弃用标签或类似标签
I cannot find any deprecation tags or such
http://api.jquery.com/category/deprecated/给出了404
如果我在迁移模块. net/mplungjan/cBgtn/"rel =" noreferrer> jsFiddle然后起作用,我在控制台中看到警告(由 https://github.com/jquery/jquery-migrate/blob/master/warnings.md )
If I add the Migrate module my jsFiddle then works and I see the warning in the console (elaborated by https://github.com/jquery/jquery-migrate/blob/master/warnings.md as posted by Frédéric Hamidi)
我看到弃用fn切换和问题24 和机票#11786 ,但不在我希望看到的地方.
I see Deprecate fn toggle and issue 24 and Ticket #11786 but not in places I would expect to see it.
我缺少什么?在哪里可以找到它的替代品和文件?
What am I missing and where do I find the replacement and documentation for it?
注意:我了解过时的原因,只是找不到过时的官方文档
NOTE: I understand the reason for deprecation, I just can't find official documentation for the deprecation
$('#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());
}
});
}
);
迁移代码:
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,因此它是重命名而不是删除
UPDATE I have asked if they could keep the code as fn.toggler so it is a rename instead of a remove
推荐答案
您可以找到有关 jQuery Migrate插件发出的警告列表:
原因:.toggle()
有两种完全不同的含义 方法.使用.toggle()
来显示或隐藏元素不受影响. 在.toggle()
中将其用作专门的单击处理程序已被弃用 1.8,并在1.9中删除.
Cause: There are two completely different meanings for the .toggle()
method. The use of .toggle()
to show or hide elements is not affected. The use of .toggle()
as a specialized click handler was deprecated in 1.8 and removed in 1.9.
解决方案:重写依赖于$().toggle()
的代码,使用 jQuery Migrate插件的最小生产版本,以提供 功能,或从中提取$().toggle()
方法 插件的来源,并在应用程序中使用它.
Solution: Rewrite the code that depends on $().toggle()
, use the minified production version of the jQuery Migrate plugin to provide the functionality, or extract the $().toggle()
method from the plugin's source and use it in the application.
这篇关于fn.toggle(handler(eventObject),handler(eventObject)...)哪里去了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!