Uncaught Error: Syntax error, unrecognized expression: #

user1084319 picture user1084319 · Oct 9, 2012 · Viewed 18k times · Source

I am trying to obtain a cell's text value from a flexigrid. However I keep getting that error.

This is my function for retrieving a specific cell's text(Flexigrid doesnt have "attr" it has "abbr" instead).

function getSelectedCopyDates() {
    var arr = new Array();
    debugger;
    //for every row that has a checked checkbox
    $("tr").has(".noteCheckBox:checked").each(function(i) {
        if ($(this.id) !== "checkAllNotes") {
            //push the value of column(FName, LName) into the array 
            arr.push($("#" + this.id + "> td[abbr='EventDate'] > div").text());
        }
    });
    return arr;
}

I only get that error when I click on "checkAllNotes"(main check box ). If I check a checkbox manually then everything works fine.

Here is my flexigrid layout:

$('#viewNotesGrid').flexigrid({
    url: url,
    dataType: 'json',
    method: 'get',
    colModel: [{
        display: '<input type="checkbox" class="noteCheckBox" id="checkAllNotes" />',
        name: 'checkBox',
        width: 20,
        sortable: false,
        align: 'center',
        process: showDescription
    }, {
        display: 'Date',
        name: 'EventDate',
        width: 80,
        sortable: true,
        align: 'center',
        process: showDescription
    },

Answer

Explosion Pills picture Explosion Pills · Oct 9, 2012

I think you mean to use this.id == vs. $(this.id) ==. It also seems like the error may be because this.id is empty (jQuery will throw that error on $("#>"), but the error message also seems to include the >, so I'm not sure).