dialog button functions running when dialog loaded

dialog button functions running when dialog loaded

i have been working with jquery dialog for a while and am stuck on a new problem today.

when i load a dialog, it is running the button functions when the dialog is opened.

anyone got any ideas?

$(function() {


   var dialogopts = {
      modal:true,
      autoOpen:false,
      draggable:false,
      resizable:false,
      buttons: {
         "Search" : doSearch
      },
      width:460,
      height:250
   };
   $('div#despatch').dialog(dialogopts);

   


});
function doSearch() {
      alert("yikes");
   }