JQuery FIX: uncaught exception: Syntax error, unrecognized expression: #

Leave a comment Standard

This one threw me for a bit of a loop today so I thought I’d share. I couldn’t get my debugger to give me a line number for this error, however it turns out I had a double # sign in my jQuery code.

<script>
$("##myButton").click(function () { alert('You are pressing my buttons'); });
</script>

Notice the duplicate pound sign (#) in the ID reference for the button. Remove the duplicate pound sign and you should be good to go.

DOJO Grid FIX: Showing/Hiding Grid Causes Grid Headings To Disappear

Leave a comment Standard

DOJO has a quirky problem if you try to show/hide grids using Javascript or JQuery. This is especially trying if you have multiple grids on a page and you only want to display one at a time. If your column headers aren’t “fixed” they disappear once you hide the grid and then try to display it again.

The only way around this is to use the .resize() method on the grid reference after you try to show it again. This re-draw the grid with all the columns showing up again.

<script>

$("#showSubGridButton").click(function() {
    $("#mainGridContainer").hide();
    $("#subGridContainer").show();
    refreshGrid(subGrid);
});
$("#showMainGridButton").click(function() {
    $("#subGridContainer").hide();
    $("#MainGridContainer").show();
    refreshGrid(mainGrid);
});
function refreshGrid(gridRef) {
   gridRef.resize();
}
</script>