IE6 中的 jQuery 工具提示

发布于 2024-10-22 00:06:48 字数 3945 浏览 6 评论 0原文

我目前正在与 jQuery 工具工具提示作斗争。它在 IE8/Firefox 中的工作方式与声称的一样,但客户端还需要它在 IE6 中工作。从我在他们网站上看到的一切,以及它在项目其他地方工作的事实,我知道它与 IE6 兼容。

我相信挂起的原因是我将工具提示附加到 AJAX 生成的表行列表。到目前为止,我已经尝试过这两种方法,这两种方法似乎都在 IE8/Firefox 中工作,但在 IE6 中都不起作用。

尝试 1:

        $(document).ready(function() {
                // get the undeclared additions and populate the table
                $.getJSON("/Drm/Pc/GetUndeclaredAssistanceRecords?partnumber=<%= Model.PartNumber %>",
                function(data) {
                    var rowEntry = "";
                    var rowClass = "odd";
                    for (var i = 0; i < data.length; i++) {

                        // Fix for Bug 71 starts
                        strComment = "";
                        for (var k = 0; k < data[i].Comment.length; k++) {
                            if (data[i].Comment.substring(k, k + 1) == "'")
                                strComment = strComment + "";
                            else
                                strComment = strComment + data[i].Comment.substring(k, k + 1);
                        }

                        strComment = strComment.replace(";", ",");
                        strComment = strComment.substring(0, 400);

                        var rowEntry = "<tr class='" + rowClass + "'><td class='pcassistresultsCenterAlign'>" + data[i].PurchaseOrder + "</td><td class='pcassistresultsLeftAlign'>" + data[i].SupplierName + "</td><td class='pcassistresultsCenterAlign'>" + data[i].Amount + "<td class='pcassistresultsCenterAlign'>" + data[i].RecordType + "</td></tr>";
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle'>Shipment Date:</td><td>" + data[i].ShipDate + "</td><td class='pcassistresultsDetailTitle'>Input On:</td><td class='pcassistresultsDetailData'>" + data[i].InputOn + "</td></tr>";
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle'>Req Recon:</td><td class='pcassistresultsDetailData'>" + data[i].ReqRecon + "</td><td class='pcassistresultsDetailTitle'>Input By:</td><td class='pcassistresultsDetailData'>" + data[i].InputBy + "</td></tr>";
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle'>From Site</td><td class='pcassistresultsDetailData'>" + data[i].FromSite + "</td><td class='pcassistresultsDetailTitle'>Input By Phone:</td><td class='pcassistresultsDetailData'>" + data[i].InputByPhone
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle' valign='top'>Comment:</td><td colspan='3' rowspan='2' title='" + strComment + "' ><div style='overflow:hidden; height:30px;'>" + data[i].Comment + "</div></td></tr>";


                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td>&nbsp;</td></tr>";

                        //Fix for Bug 71 ends

                        $('#unDecAddTable tbody>tr:last').after(rowEntry);
                        rowClass = rowClass == 'odd' ? 'even' : 'odd';
                        }
                        $('#unDeclaredAdditions *').tooltip();
                });
            });

尝试 2 与上面相同,但删除了 .tooltip() 部分,并在 document.ready 函数外部添加了以下代码

        function PinTooltips() {
            $('#unDeclaredAdditions *').tooltip();
            $('#declaredAdditions *').tooltip();
        }
        $('#declaredAdditions').ajaxComplete(function(event, request, settings) {
            PinTooltips();
        });

有谁看到我哪里出错了,或者知道 IE6 的一些不寻常的地方会阻止它工作?

I'm currently fighting with the jQuery Tools Tooltip. It works as claimed in IE8/Firefox, but the client also needs it to work in IE6. From everything I saw on their site, as well as the fact that it works elsewhere in the project, I know it is compatible with IE6.

I believe the hang-up is coming on the fact that I am attaching the tooltip to an AJAX generated list of table rows. I have thus far attempted this two ways, both of which seem to work in IE8/Firefox, neither of which work in IE6.

Attempt 1:

        $(document).ready(function() {
                // get the undeclared additions and populate the table
                $.getJSON("/Drm/Pc/GetUndeclaredAssistanceRecords?partnumber=<%= Model.PartNumber %>",
                function(data) {
                    var rowEntry = "";
                    var rowClass = "odd";
                    for (var i = 0; i < data.length; i++) {

                        // Fix for Bug 71 starts
                        strComment = "";
                        for (var k = 0; k < data[i].Comment.length; k++) {
                            if (data[i].Comment.substring(k, k + 1) == "'")
                                strComment = strComment + "";
                            else
                                strComment = strComment + data[i].Comment.substring(k, k + 1);
                        }

                        strComment = strComment.replace(";", ",");
                        strComment = strComment.substring(0, 400);

                        var rowEntry = "<tr class='" + rowClass + "'><td class='pcassistresultsCenterAlign'>" + data[i].PurchaseOrder + "</td><td class='pcassistresultsLeftAlign'>" + data[i].SupplierName + "</td><td class='pcassistresultsCenterAlign'>" + data[i].Amount + "<td class='pcassistresultsCenterAlign'>" + data[i].RecordType + "</td></tr>";
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle'>Shipment Date:</td><td>" + data[i].ShipDate + "</td><td class='pcassistresultsDetailTitle'>Input On:</td><td class='pcassistresultsDetailData'>" + data[i].InputOn + "</td></tr>";
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle'>Req Recon:</td><td class='pcassistresultsDetailData'>" + data[i].ReqRecon + "</td><td class='pcassistresultsDetailTitle'>Input By:</td><td class='pcassistresultsDetailData'>" + data[i].InputBy + "</td></tr>";
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle'>From Site</td><td class='pcassistresultsDetailData'>" + data[i].FromSite + "</td><td class='pcassistresultsDetailTitle'>Input By Phone:</td><td class='pcassistresultsDetailData'>" + data[i].InputByPhone
                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td class='pcassistresultsDetailTitle' valign='top'>Comment:</td><td colspan='3' rowspan='2' title='" + strComment + "' ><div style='overflow:hidden; height:30px;'>" + data[i].Comment + "</div></td></tr>";


                        rowEntry = rowEntry + "<tr class='" + rowClass + "'><td> </td></tr>";

                        //Fix for Bug 71 ends

                        $('#unDecAddTable tbody>tr:last').after(rowEntry);
                        rowClass = rowClass == 'odd' ? 'even' : 'odd';
                        }
                        $('#unDeclaredAdditions *').tooltip();
                });
            });

Attempt 2 is the same as above, but with the .tooltip() piece removed and the following code added outside the document.ready function

        function PinTooltips() {
            $('#unDeclaredAdditions *').tooltip();
            $('#declaredAdditions *').tooltip();
        }
        $('#declaredAdditions').ajaxComplete(function(event, request, settings) {
            PinTooltips();
        });

Does anyone see where I went wrong or know something unusual about IE6 that would inhibit this from working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↙温凉少女 2024-10-29 00:06:48

好吧,我发现了问题......这很奇怪。
在项目的其他地方,它正在将工具提示分配给非常大的字段。在除 IE6 之外的每个浏览器中,它都没有像我需要的那样将所述工具提示分配给注释 td。但由于某种原因,在 IE6 中,它是这样的。因此,当我尝试再次调用 .tooltip() 时,它就崩溃了。结果,我最终输入代码来检查浏览器是否为 IE6。如果是 IE6,请不要尝试重新附加工具提示。

很奇怪,我不知道为什么会这样,但这就是我的解决方案。

Okay, I found the problem...and this is weird.
Elsewhere in the project, it was assigning tooltips to a very large span of fields. In every browser except IE6, it was not assigning said tooltip to the comments td like I needed it to. But for some reason, in IE6, it was. So, when I tried to call the .tooltip() again it was breaking. As a result, I ended up putting in code to check for the browser being IE6. If it was IE6, don't try to re-attach the tooltip.

Very strange and I have no idea why it works that way, but that was my solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文