jquery – jqGrid throws“未捕获的语法错误,无法识别的表达式:#”

前端之家收集整理的这篇文章主要介绍了jquery – jqGrid throws“未捕获的语法错误,无法识别的表达式:#”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
大家好大家:)对于长代码列表我很抱歉,但我不知道我在哪里拧紧这里。我正在编写一个内部使用的jQuery插件来编辑访问控制列表。

ACL编辑器的一个组件是jqGrid插件,它是一个优秀的网格实现,它具有自己的AJAX加载设施等。我以前使用过这个组件,但是从来没有尝试过使用它作为插件的子组件。 AJAX请求被正确发送(从我在Chrome调试器中看到的),这导致我相信错误不在于我的代码,但我不确定该怎么做。

我很抱歉大量的代码,但这是我想到的最小的例子。

/*global jQuery*/
"use strict"; /* Enable ECMAScript 5 Strict Mode if supported */
(function ($) {
    var methods,defaults;

    methods = {
        init: function (options) {
            var sid,pager,enumerateUrl;
            if (this.data('isAclEditor')) {
                $.error('The targeted element is already an ACL Editor.');
            } else {
                this.data('isAclEditor',true);
            }
            this.data('options',$.extend(true,{},defaults,options));
            /*
             <div class="ui-jqgrid ui-widget ui-widget-content">
                <div class="ui-jqgrid-titlebar ui-widget-header ui-helper-clearfix">
                    <span class="ui-jqgrid-title">TITLE</span>
                </div>
                <table class="sidList"></table>
                <div class="sidPager"></div>
                <div class="privSlideout" style="display:none;">
                    <table cellspacing="0" cellpadding="0" border="0">
                        <thead>
                            <tr>
                                <th class="ui-th-column ui-state-default" colspan="3" class="privLabel"></th>
                            </tr>
                            <tr>
                                <th class="ui-th-column ui-state-default" style="width: 50px;">Allow</th>
                                <th class="ui-th-column ui-state-default" style="width: 50px;">Deny</th>
                                <th class="ui-th-column ui-state-default" style="width: 520px;">Privilege</th>
                            </tr>
                        </thead>
                        <tbody class="privTable">
                        </tbody>
                    </table>
                    <button class="btnOk">Ok</button>
                    <button class="btnCancel">Cancel</button>
                </div>
                <div style="display:none;" class="newPrivPicker">
                    <div style="font-size: 10pt">
                        <table class="newPrivTable"></table>
                        <div class="newPrivPager"></div>
                    </div>
                </div>
             </div>
             */
            this.html('<div class="ui-jqgrid ui-widget ui-widget-content"><div class="ui-jqgrid-titlebar ui-widget-header ui-helper-clearfix"><span class="ui-jqgrid-title">' + this.data('options').title + '</span></div><table class="sidList"></table><div class="sidPager"></div><div class="privSlideout" style="display:none;"><table cellspacing="0" cellpadding="0" border="0"><thead><tr><th class="ui-th-column ui-state-default" colspan="3" class="privLabel"></th></tr><tr><th class="ui-th-column ui-state-default" style="width: 50px;">Allow</th><th class="ui-th-column ui-state-default" style="width: 50px;">Deny</th><th class="ui-th-column ui-state-default" style="width: 520px;">Privilege</th></tr></thead><tbody class="privTable"></tbody></table><button class="btnOk">Ok</button><button class="btnCancel">Cancel</button></div><div style="display:none;" class="newPrivPicker"><div style="font-size: 10pt"><table class="newPrivTable"></table><div class="newPrivPager"></div></div></div></div>');
            pager = $('.sidPager',this);
            enumerateUrl = this.data('options').aclControllerUrl + '/enumerate/aclid/' + this.data('options').aclId;
            sid = $('.sidList',this).jqGrid({
                url: enumerateUrl,datatype: 'json',mtype: 'GET',colNames: ['Type','Name'],colModel: [
                    {name: 'type',index:'type',width: 20,align: 'center',sortable: false},{name: 'displayName',index:'displayName',sortable: false}
                ],rowNum: 10,rowList: [10,100,1000],autowidth: true,height: 'auto',forceFit: true,gridview: true,pager: pager
            });
            sid.navGrid(pager,{
                edit:false,add:false,del:false,search:false,refresh:true,refreshtitle: 'Refresh Users and Groups'
            });
            return this;
        }
    };

    defaults = {
        aclId: 0,title: 'Permissions Editor',aclControllerUrl: ''
    };

    $.fn.acleditor = function (method) {
        if (methods[method]) {
            return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this,arguments);
        } else {
            $.error('Method ' +  method + ' does not exist on jQuery.AclEditor.');
        }
        return null;
    };

}(jQuery));

为什么在Jquery.js的第75行获得“未捕获的语法错误,无法识别的表达式:#”?

哦,我正在使用jqgrid 3.8.1和jquery 1.4.2。

编辑:返回的JSON是:

{"rows":[{"id":"7109766F-DC8A-4134-8C1F-02F87A72DE9C","cell":["Group","Developers"]},{"id":"22EEB0C5-6792-4C24-8047-B187D38F63EC","Users"]}],"page":1,"total":1,"records":2}

解决方法

好的,对不起大家。发现问题 – 结果jqGrid保存表标记的ID,然后使用该标记引用表。给予< table>一个ID解决了问题。
原文链接:https://www.f2er.com/jquery/182740.html

猜你在找的jQuery相关文章