撇号不会让我删除项目

I have a CMS where I can create/delete items/menus/pages etc. I have a onclick jquery script that deletes something once you click an icon. Problem I am having is that when I have a page/menu/item with an apostrophe within its name, I am unable to delete it.

Here is snippets of my code:

jquery:

function confirmDeleteMenuItem(mi_id, mi_name) {
if (confirm('Are you sure you want to delete the menu item \''+mi_name+'\'?
Note: All sub-items will also be deleted.')) {
    $.ajax({
        dataType:  'json',
        url: cmsRelPath+'/app/menus/ajax_delete_menu_item.php',
        type: 'POST',
        data: {
            mi_id: mi_id
        },

php:

$cell .= '<img src="'.$cms_settings["cms_relative_dir"].'/images/icon_delete.png" width="30" height="30" border="0" alt="delete" title="Click to delete item." class="cursorPointer" onclick="confirmDeleteMenuItem('.$row->mi_id.',\''.html_entities($row->mi_name).'\');" />';

Could anyone help me with this issue?

You can use double quotes in confirm():

if (confirm('Are you sure you want to delete the menu item "'+mi_name+'"?
Note: All sub-items will also be deleted.')) {
/* ............ */

and PHP:

$cell .= '<img src="'.$cms_settings["cms_relative_dir"].'/images/icon_delete.png" width="30" height="30" border="0" alt="delete" title="Click to delete item." class="cursorPointer" onclick="confirmDeleteMenuItem('.$row->mi_id.',\''.html_entities(str_replace("'", "\'", $row->mi_name)).'\');" />';

You can escape the apostrophe with \ symbol, like \'.