embedded if else statement

embedded if else statement


Ok, I am lost.  Well... confused.

I am trying to get a website menu system to initiate jqGrid correctly depending on the presence of IDs.
I have the menu item working correctly here (if the grid has previously been built):
  1. $("#threeeightcal").click( function() {
  2. var muniitonType = $('#searchResults').jqGrid('getGridParam','xmlReader:row');
  3. if (munitionType = 'bullet') {
  4. $("#searchResults").jqGrid('setGridParam',{url:"weaponLib/sa-bullet38cal.xml"}).trigger("reloadGrid");
  5. };
  6. });
All good so far. 
Now I need to modify it so that it tests for the presense of id "gbox_searchResults".  gbox will always get built if jqGrid has been previously initiated.  But my script is always going to the else statement.  What simple thing am I doing wrong??  I have verified that when website first appears and user has control of menu system that the id gbox_searchResults is not even in the DOM.  So my return should be a false.

Broke code:
  1. $("#threeeightcal").click( function() {
  2. var gridBuilt = $('#gbox_searchResults');
  3. var muniitonType = $('#searchResults').jqGrid('getGridParam','xmlReader:row');
  4. if (!(gridBuilt)) alert("your a dummy");
  5. // completely re-init jqGrid
  6. else alert("good to go");
  7. // reload grid with new static xml file
  8. });
It is not the job you get handed, but what you have done with it in the end that people remember.