Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling selected row in jqGrid only works once
    primarykey
    data
    text
    <p>Alright, this has to be something stupid but I haven't been able to spot it...</p> <p>I've got a jqGrid with id "grid" (inspired, I know). I'm adding a nav button to the grid as such:</p> <pre><code>jQuery("#grid").navButtonAdd('#pager', { caption : "Manage Files", onClickButton : function(){ var rowid = $('#grid').jqGrid('getGridParam', 'selrow'); if(rowid == null) alert('Please select a record before trying to manage files'); makeUploadDialog(rowid); } }); </code></pre> <p>So, this works. The first time you do it. If you click another row and hit the button again, I get this error:</p> <pre><code>Uncaught TypeError: Object [object Object] has no method 'jqGrid' </code></pre> <p>I'm guessing there's some bad mojo going on with the ordering of events, but I know I've seen this exact approach used by Oleg in a stack post (albeit a 2 year old one).</p> <p>Any suggestions?</p> <p>[EDIT to add more code and context]</p> <p>I discovered that this problem was being triggered somehow by the AJAX loading of the content for the dialog. I've done this type of operation on other projects without an issue, so I'm confused why it would be causing me to "lose context" in this case. If I comment out the last line below...the load call, I can open and close the dialog repeatedly and maintain grid functionality. I just don't understand why...</p> <pre><code>function makeUploadDialog(rowID) { var dialog = $('&lt;div&gt;&lt;/div&gt;').appendTo('body'); dialog.dialog({ width: 850, autoOpen: true, draggable: true, resizable: false, title: 'Manage Artifacts', buttons: { Close: function () { $("#grid").trigger("reloadGrid"); dialog.remove(); } }, close: function () { $("#grid").trigger("reloadGrid"); dialog.remove(); } }); dialog.load('getUploadDialog.html?rowId='+rowID); </code></pre> <p>[EDIT x2]</p> <p>I've just discovered that the #grid object looks to have been corrupted somehow by the #.load? I did a console.log of the $('#grid') and can see that it is in fact missing all the jqGrid methods, but has some content that seems like it belonged in the dialog (like a reference to the MultiFile object...which is part of MultiFile.js used in the dialog itself for some file uploading). Truly perplexing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload