Dialog Buttons don't work in Greasemonkey

Dialog Buttons don't work in Greasemonkey

I'm trying to create a dialog box in Greasemonkey and everything goes well until I add buttons. If I remove the "buttons:" part of the dialog function, it functions as expected (just without buttons obv).

// ==UserScript==
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// @require      http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js
// ==/UserScript==

$('head').append('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css"/>');
$('body').append('<div id="dialog">'+'hello'+'</div>');

$(function() {
    $( "#dialog" ).dialog({
        modal: true,
        resizable: false,
        buttons: {
            'cancel': function() {

$( "#dialog" ).dialog('open');