2013-06-05 5 views
1

대화 상자에 이전 버튼을 놓지 않고 새 버튼을 추가하고 싶습니다. 내가 작동하지 않았다 다음 코드를 사용했다 ....Jquery UI 대화 상자 위젯 추가 버튼

menu.dialog("open"); 
       var buttons = menu.dialog("option", "buttons"); 
       //$.extend(buttons, {text: label, click: function(){ alert("Added New Poker Face"); } }); 
       buttons[label] = function() { alert("Addded New poker Face"); }; 
       menu.dialog("option", "buttons", buttons);      

심지어 행운 위에 주석 버튼 목록을 덮어 확장 사용했다 PLZ이

답변

0
에 대한 주위의 모든 작업

doc.dialog("option", "buttons")의 반환 값이 객체 {label1: click1, label2: click2, ...}이거나 배열 [{"text": label1, "click": click1}, {"text": label2, "click": click2}, ...] 일 수 있다고 말합니다.

buttons의 형식을 확인 했습니까? 배열 인 경우 새 버튼 .push()을 입력해야합니다.

+0

그것은 개체를 반환합니다 ..... 그것이 나를 위해 일한 다음과 같은 일을 할 수 있습니다. 그 기능이 작동하지 않지만 확장 기능을 사용했습니다. – user1840841

0

우리는

   //gets the list of buttons. 
       var buttons = menu.dialog("option", "buttons"); 
       //Adds the new button to the existing list of buttons. 
       buttons.push({ text: label, click: function() { alert("Addded New poker Face"); } });     
       //Gives the new list of buttons to the dialog to display. 
       menu.dialog("option", "buttons", buttons);