jQuery UI - 这相当于什么
jQuery UI - What does this equate to?
我正在阅读我正在扩展的jquery-ui小部件的源代码,我完全被这行代码难住了。
this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement
如果我理解正确,这意味着上述内容只能等同于两件事:
this.placeholder["next"]()[0] !== itemElement
this.placeholder["prev"]()[0] !== itemElement
它想做什么?它如何执行数组键?
这是定义this.placeholder
的地方:
_createPlaceholder: function(that) {
that = that || this;
var className,
o = that.options;
if(!o.placeholder || o.placeholder.constructor === String) {
className = o.placeholder;
o.placeholder = {
element: function() {
var nodeName = that.currentItem[0].nodeName.toLowerCase(),
element = $( "<" + nodeName + ">", that.document[0] )
.addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
.removeClass("ui-sortable-helper");
if ( nodeName === "tr" ) {
that.currentItem.children().each(function() {
$( "<td> </td>", that.document[0] )
.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
.appendTo( element );
});
} else if ( nodeName === "img" ) {
element.attr( "src", that.currentItem.attr( "src" ) );
}
if ( !className ) {
element.css( "visibility", "hidden" );
}
return element;
},
update: function(container, p) {
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
if(className && !o.forcePlaceholderSize) {
return;
}
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
}
};
}
//Create the placeholder
that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
//Append it after the actual current item
that.currentItem.after(that.placeholder);
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
o.placeholder.update(that, that.placeholder);
}
如果有人能对此有所了解,我将不胜感激。
它正在获取上一个或下一个 DOM 元素。由于 jQuery 返回一个类似数组的对象,因此[0]
是存储的第一个 DOM 项。
this.placeholder.prev()
与
this.placeholder["prev"]()
后者称为括号表示法。
相关文章:
- 什么's是相当于LINQ's SelectMany运算符
- 什么's相当于AngularJS中的jQuery.one()
- 在 JavaScript 中相当于什么
- 什么是 FORM 相当于 DOM 的 getNextSibling
- 什么是 JavaScript 相当于 php 的FILTER_SANITIZE_STRING
- 什么是节点.js相当于窗口[“myvar”] = 值
- 什么是 js 相当于 RailsInstaller
- jQuery UI - 这相当于什么
- JS:相当于async.each的承诺是什么
- 什么是node's相当于Perl'神奇的“tie()”机制(挂钩/拦截对变量的访问)
- 什么是相当于_.勇气的物体
- 什么'相当于Javascript中的.sample
- 什么's相当于Javascript's C#中的Object.assign()
- 什么是“设置”HTML"相当于appendTo和prependTo
- 什么是ES6承诺相当于jQuery Deferred's 'always ' ?
- 什么是NodeJs相当于Java的getBytes()
- 在emberjs组件中,什么'相当于Angular'的指令链接函数?
- 什么'这相当于javascript中的.get吗
- 什么是相当于.net 's DateTime的javascript.日期属性
- eslint中的jscs ' disallowKeywordsOnNewLine '相当于什么?