$(document).ready(function() {
  $("#rating_dialog a").click(function () {
    var rating_val = $(this).prev()[0].alt;
    var url = $(this)[0].rel;
    $.post(url, {'rating': rating_val },  function() { $("#rating_dialog").dialog('close'); window.location.reload(); })
  });

  var change_buttons_on_submit = function() {};

  $(".rate-button").click(function() { 
    $("#rating_dialog").dialog({ // and recreate it with following options
                          title: "Rate",
                          modal: true,
                          height: 500,  
                          width: 700,
                          bgiframe: true,
                          buttons: {
                              'Close': function() {
                                  $(this).dialog('close'); }
                          },
                          close: function() { },
                          open: function() { $(this).hijack(change_buttons_on_submit)} /// This is where hijack() magic happens.
                      });
                    });
});