我在 IE9 中有一个奇怪的问题。
如果我将输入元素放在颜色框(内联 HTML)中,然后在所述输入元素具有焦点的情况下按 Enter - 颜色框会关闭吗?
这在 Chrome 中不会发生。
我设置了一个 jsfiddle 来演示这个问题:
- 打开小提琴:http: //jsfiddle.net/rv74f/3/
- 单击内联 HTML链接
- 单击生成的文本框以使其获得焦点
- 按键盘上的 Enter - Colorbox 然后淡出?
我在选项中看不到任何阻止/解释这种行为的内容?
我怎样才能防止 Enter 关闭颜色框,而不是在我的所有输入元素上捕获按键事件?
我快速浏览了彩盒源代码并注意到了诸如escKey: true,
但我看不到任何可以解释此 Enter Key 问题的参数?
编辑:
如果我将以下内容添加到publicMethod.close()
alert("caller is " + arguments.callee.caller.toString());
它告诉我 .close() 被调用publicMethod.close()
如果我添加以下内容(注意使用 caller.caller 进一步向上移动堆栈):
alert("caller is " + arguments.callee.caller.caller.toString());
我得到以下信息:
---------------------------
Message from webpage
---------------------------
caller is
function( event ) {
// Make a writable jQuery.Event from the native event object
event = jQuery.event.fix( event );
var i, ret, handleObj, matched, j,
handlerQueue = [],
args = core_slice.call( arguments ),
handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[0] = event;
event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
return;
}
// Determine handlers
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
// Run delegates first; they may want to stop propagation beneath us
i = 0;
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem;
j = 0;
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
event.handleObj = handleObj;
event.data = handleObj.data;
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
.apply( matched.elem, args );
if ( ret !== undefined ) {
if ( (event.result = ret) === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}
}
}
// Call the postDispatch hook for the mapped type
if ( special.postDispatch ) {
special.postDispatch.call( this, event );
}
return event.result;
}
---------------------------
OK
---------------------------
那么 colorbox.close() 方法是由 JQuery 函数调用的吗?现在我只需要弄清楚为什么......
谜团越来越深......