2011-10-17 7 views
0

下のパネルのボタンに名前(図示のテキストではありません)を追加しようとしていますが、その方法を見つけることができません。JQueryダイアログ下のボタンに名前を追加する

これは私がこれまでに...

$("#dialog-import-from-existing").dialog({ 
     title: "Import From Existing", 
     autoOpen: false, 
     modal: true, 
     draggable: false, 
     resizable: false, 
     width: 500, 
     height: 525, 

      buttons: { 
       **name : "SubmitButton",** 
       "Import": function() { 
       $('#CreateForm').submit(); 
       $(this).dialog('close'); 
      }, 
      "Cancel": function() { 
       //Need to added the js files to Driver studio. 
       //$("models-to-add-container").effect("explode"); 
       $(this).dialog('close'); 
      } 
      } 
     }); 

は私が名前を「サブミット」で、このボタンを持ってしようとしているものです。

ありがとうございます。

答えて

0

ボタンオプションは、2つのAPIがあります。ボタンのラベルをクリック機能にマッピングする、元の、より簡単なAPIを使用しています。オブジェクトの配列を使用することもできます。これにより、より多くの制御が可能になります。

$("#dialog-import-from-existing").dialog({ 
    ... 
    buttons: [ 
     { 
      name: "SubmitButton", 
      text: "Import", 
      click: function() { 
       $("#CreateForm").submit(); 
       $(this).dialog("close"); 
      } 
     }, 
     { 
      text: "Cancel", 
      click: function() { 
       $(this).dialog("close"); 
      } 
     } 
    ] 
}); 

このAPIを使用すると、.attr()プラスイベントハンドラに渡すことができるものを渡すことができます。

0

試してみてください(jQuery UI Dialog Button Iconsから精製)

$("#dialog-import-from-existing").dialog({ 
    ... 
    open: function() { 
     $(this).parent().find('.ui-dialog-buttonpane button:contains("Import")'). 
      attr('name', 'SubmitButton'); 
    } 
}); 

関連する問題