Search code examples
javascriptjqueryhtmlhref

confirmation message is not firing a href onclick


below is only a part of my javascript code. confirmation message is not firing.

 function PKId_delete_formatter(cellvalue, options, rowObject) {
    return '<a href="JqGridClients/Delete?id=' + cellvalue + '" onclick="return confirm("Are you sure want to delete?");" class="ui-icon ui-icon-trash"></a>';
}

I think the above code is enough, please let me know if more code is needed


Solution

  • Use this:

    return '<a href="JqGridClients/Delete?id=' + cellvalue + '" onclick="return confirm(\'Are you sure want to delete?\');" class="ui-icon ui-icon-trash"></a>';
    

    It inserts the proper quotes for the confirm.

    DEMO: http://jsfiddle.net/BS5u6/1/