1

我目前正在开发一个 phonegap/cordova 应用程序。我有一个 iOS 和 Android 构建工作/运行,并且都使用 JQGrid/JQPlot。我已将我的 jquery 代码更新为 win8 版本并摆脱了讨厌的异常。但是,我现在收到相同的无法通过 JQGrid/JQPlot 的实现添加动态内容异常。话虽如此,有没有人能够找到使用这些插件中的一个或两个的解决方法?

编辑 -

我很抱歉.. 我读了太多关于它的书,我忘了把它包括在内。

这是例外。

 Unable to add dynamic content '<table><thead><tr class='ui-jqgrid-labels' role='rowheader'><th id='momMeasurementTable_Record' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Record' class='ui-th-div-ie'>Record<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Label' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Label' class='ui-th-div-ie'>Label<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Date' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Date' class='ui-th-div-ie'>Date<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Time' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Time' class='ui-th-div-ie'>Time<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MaxCurrent' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MaxCurrent' class='ui-th-div-ie'>Max Current (A)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MinCurrent' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MinCurrent' class='ui-th-div-ie'>Min Current (A)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MinCurrentLim' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MinCurrentLim' class='ui-th-div-ie'>Min Current Limit (A)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Resistance' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Resistance' class='ui-th-div-ie'>Resistance (mOhm)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_PFUpperLimit' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_PFUpperLimit' class='ui-th-div-ie'>Pass/Fail Upper Limit (mOhm)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MeasurementTime' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MeasurementTime' class='ui-th-div-ie'>Measurement Time (ms)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th></tr></thead></table>'. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement.  For more information, see http://go.microsoft.com/fwlink/?LinkID=247104.

文件:关于:空白

本质上,当生成表时,插件试图执行“不安全代码”,即使这是一个纯粹的本地应用程序并且脚本是安全的。

该异常显示在 jquery 标头中。

   append: function () {
        return this.domManip(arguments, true, function (elem) {
            if (this.nodeType === 1 || this.nodeType === 11) {
                this.appendChild(elem); //<-----------------------------
            }
        });
    },

我试过使用MSApp.execUnsafeLocalFunction(this.appendChild(elem));,我得到一个例外说..

Unhandled exception at line 5842, column 21 in ms-appx://664ace5f-4774-4928-bc94-ad4650a1ede1/js/jquery-1.8.2.js

0x80070057 - JavaScript 运行时错误:参数无效。

我不确定从哪里开始编辑/修改这些库文件以允许“不安全”注入 html/scripts 以允许我的应用程序像在 iOS/Android 上一样运行。

任何想法/帮助将不胜感激。

4

1 回答 1

0

对 JQGrid 来说没问题。使其工作的关键如下。

在您需要更改的 JQUERY 代码中...我得到了帮助...使用 jQuery 构建 Windows 8 Metro 应用程序 我将答案留在这里,因为它也应该指导那些在此处寻找 JQGrid/JQPlot 问题的人。

append: function () {
            return this.domManip(arguments, true, function (elem) {
                if (this.nodeType === 1 || this.nodeType === 11) {
                    this.appendChild(elem);
                }
            });
        },        

before: function () {
            if (!isDisconnected(this[0])) {
                return this.domManip(arguments, false, function (elem) {
                    this.parentNode.insertBefore(elem, this);
                });
            }

到以下... 注意只有在您知道代码是安全的情况下才这样做。

 append: function () {
            return this.domManip(arguments, true, function (elem) {
                if (this.nodeType === 1 || this.nodeType === 11) {
                    var self = this;
                    MSApp.execUnsafeLocalFunction(function () { self.appendChild(elem) });
                }
            });
        },


      before: function () {
            if (!isDisconnected(this[0])) {
                return this.domManip(arguments, false, function (elem) {
                    var self = this;
                    MSApp.execUnsafeLocalFunction(function () { self.parentNode.insertBefore(elem, self)});
                });
            }

第二注。我仍然在我的日志中收到 HTML 错误,但是它可以正确加载。HTML错误看起来像..

HTML1701: Unable to add dynamic content '<table><thead><tr class='ui-jqgrid-labels' role='rowheader'><th id='momMeasurementTable_Record' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Record' class='ui-th-div-ie'>Record<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Label' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Label' class='ui-th-div-ie'>Label<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Date' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Date' class='ui-th-div-ie'>Date<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Time' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Time' class='ui-th-div-ie'>Time<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MaxCurrent' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MaxCurrent' class='ui-th-div-ie'>Max Current (A)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MinCurrent' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MinCurrent' class='ui-th-div-ie'>Min Current (A)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MinCurrentLim' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MinCurrentLim' class='ui-th-div-ie'>Min Current Limit (A)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_Resistance' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_Resistance' class='ui-th-div-ie'>Resistance (mOhm)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_PFUpperLimit' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_PFUpperLimit' class='ui-th-div-ie'>Pass/Fail Upper Limit (mOhm)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th><th id='momMeasurementTable_MeasurementTime' role='columnheader' class='ui-state-default ui-th-column ui-th-ltr'><div id='jqgh_momMeasurementTable_MeasurementTime' class='ui-th-div-ie'>Measurement Time (ms)<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr'></span><span sort='desc' class='ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr'></span></span></div></th></tr></thead></table>'. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement.  For more information, see http://go.microsoft.com/fwlink/?LinkID=247104.

文件:关于:空白

于 2013-01-10T18:42:48.030 回答