- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 jquery 对话框在 Firefox 中无法正常工作,但 Firebug 不会给我任何错误。我的对话框在 Chrome 中运行得非常好。
情况:我的页面上有几个 jquery 对话框,它们在不同的事件上打开。一个“添加新元素”对话框给我带来了问题。第一次打开对话框时效果很好。随后的任何时候,都无法单击或键入文本输入框。我想我每次都会通过销毁对话框来解决问题。然后每次打开它时它都会起作用。但后来我发现,如果打开任何其他对话框,然后打开这个“添加新元素”对话框,同样的事情会再次发生:无法在框中输入。
我很困惑!!!!请提供任何帮助,我们将不胜感激...我已经盯着这段代码好几天了。
这是 jquery 对话框代码:
$(function() {
$( "#dialog-new-osc-el" ).dialog({
resizable: false,
autoOpen: false,
height:300,
width:400,
modal: true,
buttons: {
"Create": function() {
*create button function stuff here* then:
$(this).dialog("destroy");
$( this ).dialog( "close" );
create_new_osc_el_dialog();
},
Cancel: function() {
$(this).dialog("destroy");
$( this ).dialog( "close" );
create_new_osc_el_dialog();
}
},
close: function() {
$(this).dialog("destroy");
$( this ).dialog( "close" );
create_new_osc_el_dialog();
}
});
});
当单击“添加新元素”div 时,将打开对话框 - 该 div 有一个 onclick 函数:
<div class="addnewbox" onclick="addneweltoosc();">
这个 onclick 函数如下所示(为简洁起见,删除了一些代码):
function addneweltoosc(){
$( "#dialog-new-osc-el" ).dialog( "open" );
}
对话框的实际 HTML 相当长,以下是重要的内容:
<div id="dialog-new-osc-el" title="Create Element">
<div id="new_osc_el_type" class="pointer">
<ul>
<li onclick="new_osc_el_type_chosen('Branch');">Branch</li>
<li onclick="new_osc_el_type_chosen('Group');">Group</li>
<li onclick="new_osc_el_type_chosen('Division');">Division</li>
<li onclick="new_osc_el_type_chosen('Unit');">Unit</li>
<li onclick="new_osc_el_type_chosen('Strike Team');">Strike Team</li>
<li onclick="new_osc_el_type_chosen('Task Force');">Task Force</li>
<li onclick="new_osc_el_type_chosen('Individual Resource');">Individual Resource</li>
</ul>
</div>
<p><input class="hide" type="text" id="new_osc_el_pos_name" />
</div>
该对话框首先为用户提供一个可供选择的列表。当用户单击列表项时,将调用 new_osc_el_type_chosen 函数。此函数隐藏该列表并显示“new_osc_el_pos_name”文本输入。 这是对话框第一次打开时起作用的输入框,但之后就不再起作用。这是代码:
function new_osc_el_type_chosen(a)
{
$("#new_osc_el_type").addClass("hide");
$("#new_osc_el_pos_name").removeClass("hide");
if (a=="Branch")
{
$("#new_osc_el_pos_name").val("NAME of Branch Director");
}
document.getElementById("new_osc_el_pos_name").setSelectionRange(0,7);
$("#new_osc_el_pos_name").focus();
}
已解决!
显然,所有模态对话框都会导致它们之间发生冲突......或者其他什么。实际上,我不是 100% 确定为什么 - 但将 modal:true 更改为 modal:false 解决了我的问题。
最佳答案
我在使用 Firefox 时也遇到了同样烦人的问题。所有其他浏览器都运行良好。
我注意到定义了多个对话框的页面存在问题(所有对话框均使用 autoOpen: false
定义,因此只有用户单击触发 dialog( “打开”)
我有两个简单的对话框,每个对话框都有一个 input type="text"
和两个按钮(input type="button"
,用于“取消”和“好的”)。
我可以使用任一对话框进行重现,但一个简单的测试仅适用于一个对话框:
我尝试增加输入及其对话框 div 的 z 索引。我尝试减小模态层的 z 索引。我什至删除了模态 div 元素。这些都没有效果。然后我在 jquery-ui.js 中搜索“modal”(使用 jQuery UI - v1.9.2)并发现此部分是问题所在(我确认通过注释掉它,输入问题消失了)。
问题来源,来自 jquery-ui.js (1.9.2):
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
if ( this.options.modal ) {
maxZ = 0;
$( ".ui-dialog" ).each(function() {
if ( this !== that.uiDialog[0] ) {
thisZ = $( this ).css( "z-index" );
if ( !isNaN( thisZ ) ) {
maxZ = Math.max( maxZ, thisZ );
}
}
});
$.ui.dialog.maxZ = maxZ;
}
我在 jQuery UI 错误跟踪器上发现了#4309:http://bugs.jqueryui.com/ticket/4309
看来所有浏览器的问题都已修复,但问题仍然存在于 Firefox 中(至少在我使用的版本中) - 即使您仅打开/关闭/重新打开其中一个对话框,现在也会出现问题(因此其他对话框也在那里,但从未调用过“打开”)。
对我有用的黑客修复是在加载 jquery-ui.js 后执行此操作:
if ($.browser.mozilla)
{
// fix firefox z-index bug with modal jquery UI dialog that prevents user from typing after initial modal dialog opened
$.fn.dialogOriginal = $.fn.dialog; // save original dialog() function
$.fn.dialog = function ()
{
if (!$(this).data("fixModalZIndex"))
{
// bind events only once
$(this).data("fixModalZIndex", true).bind("dialogbeforeclose", function (event, ui)
{
// unhook modal behavior to fix firefox bug
$(this).dialog("option", "modal", false);
}).bind("dialogclose", function (event, ui)
{
var ref = $(this); // save reference for later
setTimeout(function ()
{
ref.dialog("option", "modal", true); // set back to modal, but in a timeout to avoid the z-index input bug
ref = null;
}, 0);
});
}
return $.fn.dialogOriginal.apply(this, arguments); // call original dialog function
};
}
不太懂这个。可能有助于通过 maxZ 逻辑进行调试,但我不是 Firefox 粉丝,而且由于我的 hack 修复有效,我准备关闭此票证并返回修复我自己的错误,而不是修复 jQuery 的错误。希望这个信息对某人有帮助,听起来你已经决定采用 modal:false 路线(这也对我有用,但客户真的希望它是模态的......)
关于Firefox 中的 jquery 对话框问题 : can't type after opens 1st time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11669526/
在尝试 time 的 python 执行时,我发现在一条语句中两次调用 time.time() 时出现奇怪的行为。在语句执行期间获取time.time() 有一个非常小的处理延迟。 例如time.ti
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我不明白为什么下面的结果是一样的。我预计第一个结果是指针地址。 func print(t *time.Time) { fmt.Println(t) // 2009-11-10 23:00:00
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32 Type "help
当我有一个time.Time时: // January, 29th t, _ := time.Parse("2006-01-02", "2016-01-29") 如何获得代表 1 月 31 日的 ti
首先,我意识到不推荐使用 time with time zone。我要使用它是因为我将多个 time with time zone 值与我当前的系统时间进行比较,而不管是哪一天。 IE。用户说每天 0
长期以来,在 Rust 中精确测量时间的标准方法是 time crate 及其 time::precise_time_ns功能。但是,time crate 现在已被弃用,std 库有 std::tim
我正在我学校的一个科学集群上运行我的有限差分程序。该程序使用 openmpi 来并行化代码。 当程序连续运行时,我得到: real 78m40.592s user 78m34.920s s
尽管它们已被弃用并且有比 time 更好的模块(即 timeit),但我想知道这两个函数 time 之间的区别.clock() 和 time.time()。 从后者 (time.time()) 开始,
这个问题在这里已经有了答案: Python's time.clock() vs. time.time() accuracy? (16 个答案) 关闭 6 年前。 我认为两者都衡量时间量?但是他们返回
我正在尝试测试 http 请求处理代码块在我的 Flask Controller 中需要多长时间,这是我使用的示例代码: cancelled = [] t0 = time.time() t1 = ti
运行 python 的计算机时钟(Windows 或 Linux)时会发生什么自动更改并调用 time.time()? 我读到,当时钟手动更改为过去的某个值时,time.time() 的值会变小。 最
我有一个结构可能无法在其字段之一上设置 time.Time 值。测试无效性时,我不能使用 nil 或 0。time.Unix(0,0) 也不相同。我想到了这个: var emptyTime time.
我有一个打算用数据库记录填充的结构,其中一个日期时间列可以为空: type Reminder struct { Id int CreatedAt time.Time
问题陈述:通过匹配其百分比随机执行各种命令。比如执行 CommandA 50% 的时间和 commandB 25% 的时间和 commandC 15% 的时间等等,总百分比应该是 100%。 我的问题
我正在使用 laravel 6。我在同一个应用程序中有类似的 Controller 和类似的 View ,它工作正常。对比之后还是找不到错误。 Facade\Ignition\Exceptions\V
我需要用 ("%m/%d/%Y %H:%M:%S") 格式表示时间,我得到的浮点值是 time.time(). 我已经有了一个 time.time() 形式的值。例如,我已经有一个值,我每 0.3 秒
我正在使用以下方法获取 utc 日期时间: import datetime import time from pytz import timezone now_utc = datetime.datet
我在 Ubuntu 上使用 time.clock 和 time.time 为一段 python 代码计时: clock elapsed time: 8.770 s time elapsed time
我是一名优秀的程序员,十分优秀!