2010-10-25 11 views
19

सभी को नमस्कार :) मुझे लंबी कोड सूची के लिए खेद है, लेकिन मुझे यकीन नहीं है कि मैं यहां कहां खराब हो रहा हूं। मैं अभिगम नियंत्रण सूचियों को संपादित करने के लिए एक आंतरिक उपयोग-केवल jQuery प्लगइन लिख रहा हूं।jqGrid फेंकता है "अनकॉट सिंटेक्स त्रुटि, अपरिचित अभिव्यक्ति: #"

एसीएल संपादक का एक घटक jqGrid प्लगइन है, जो एक उत्कृष्ट ग्रिड कार्यान्वयन है, जो इसकी स्वयं की AJAX लोडिंग सुविधाओं और इस तरह के साथ आता है। मैंने पहले इस घटक का उपयोग किया है, लेकिन मैंने पहले कभी प्लगइन के उप-संयोजक के रूप में इसका उपयोग करने की कोशिश नहीं की है। AJAX अनुरोध सही ढंग से भेजा जा रहा है (जो मैं क्रोम के डीबगर में देखता हूं) से, जो मुझे विश्वास दिलाता है कि बग मेरे कोड में नहीं है, लेकिन मुझे यकीन है कि इस बिंदु पर क्या करना है।

मुझे बड़ी मात्रा में कोड के लिए खेद है, लेकिन यह न्यूनतम उदाहरण है जिसे मैं सोच सकता हूं। Jquery.js की लाइन 75 पर:

/*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', align: 'center', 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)); 

क्यों मैं "# Uncaught सिंटैक्स त्रुटि, गैर मान्यता प्राप्त अभिव्यक्ति" मिलता है?

ओह, और मैं 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","cell":["Group","Users"]}],"page":1,"total":1,"records":2} 

उत्तर

48

ठीक है, खेद हर किसी को। समस्या मिली - jqGrid तालिका टैग की आईडी सहेजता है, और उसके बाद उस टैग का उपयोग कर तालिका को संदर्भित करता है। <table> देने से एक आईडी ने समस्या को ठीक किया।

+0

एक ही त्रुटि थी, एक घंटे से अधिक के लिए एक बग की तलाश में था। इस जवाब ने मुझे बचाया, धन्यवाद! इसके अलावा, यह jqGrid के पुराने संस्करणों में कोई समस्या नहीं थी। जब मैंने 3.5.3 से 3.8.2 तक अपग्रेड किया तो यह काम करना बंद कर दिया। –

+1

बस स्पष्टीकरण में मदद करने के लिए - वह इस <टेबल आईडी = "ऑर्डरटेबल"> के बजाय इस <टेबल क्लास = "ऑर्डरटेबल"> – 010110110101

+1

@ 010110110101 के बारे में बात कर रहा है: मैंने आईडी कहा, कक्षा नहीं। :) –

-1

यदि कोई भी कभी भी इस त्रुटि को "एएसपी.नेट एमवीसी के लिए jqGrid" के साथ खोजता है। मुझे "नया जोड़ें" संवाद सहेजने पर यह सटीक त्रुटि मिली है।

जैसा कि यह पता चला है, मैंने "MyGridModel.AddDialogSettings.CloseAfterAdding = true" सेट नहीं किया था;

संबंधित मुद्दे