2010-10-27 16 views
15

पर बटन जोड़ें मैं इस jquery ui संवाद में बटन नहीं जोड़ सकता। यदि संभव हो तो कृपया मुझे एक उदाहरण दें। धन्यवाद।jquery ui संवाद

<script type="text/javascript"> 
    $(document).ready(function() { 
     //setup new person dialog 
     $('#dialog2').dialog({ 
      autoResize: true, 
      show: "clip", 
      hide: "clip", 
      height: 'auto', 
      width: '1000', 
      autoOpen: false, 
      modal: true, 
      position: 'top', 
      draggable: false, 
      title: "انتخاب درخواست", 
      open: function (type, data) { 
       $(this).parent().appendTo("form"); 
      } 
     }); 

     $('#viewfaktor').dialog({ 
      autoResize: true, 
      show: "clip", 
      hide: "clip", 
      height: 'auto', 
      width: '1000', 
      autoOpen: false, 
      modal: true, 
      position: 'top', 
      draggable: true, 
      title: "مشاهده صورت ریز", 
      open: function (type, data) { 
       $(this).parent().appendTo("form"); 
      } 
     }); 


     $('#msgBox').dialog({ 


      autoResize: true, 
      show: "clip", 
      hide: "clip", 
      height: 'auto', 
      width: 'auto', 
      autoOpen: false, 
      modal: true, 
      position: 'center', 
      draggable: false, 



      open: function (type, data) { 
       $(this).parent().appendTo("form"); 
      } 


     }); 



    }); 

    function showDialog(id) { 
     $('#' + id).dialog("open"); 
    } 

    function closeDialog(id) { 
     $('#' + id).dialog("destroy"); 
    } 



</script> 

उत्तर

23
$('#msgBox').dialog({ 
    autoResize: true, 
    show: "clip", 
    hide: "clip", 
    height: 'auto', 
    width: 'auto', 
    autoOpen: false, 
    modal: true, 
    position: 'center', 
    draggable: false, 

    open: function (type, data) { 
     $(this).parent().appendTo("form"); 
    }, 

    buttons: { "OK": function() { $(this).dialog("close"); } } 
}); 
+0

कृपया मेरे सवाल फिर से मिलते हैं। मुझे अभी तक त्रुटि है – Shahin

+0

मैंने आपका कोड जोड़ा लेकिन मेरे पास वाक्यविन्यास त्रुटि है! – Shahin

+2

आह। मैंने एक अल्पविराम छोड़ दिया है। मैंने उदाहरण अपडेट किया है। –

6

Here is an example

अपने कार्य से जोड़ें:

buttons: { 
       OK: function() { //submit 
        $(this).dialog("close"); 
       }, 
       Cancel: function() { //cancel 
        $(this).dialog("close"); 
       } 
      } 

तो तुम

$('#msgBox').dialog({ 


       autoResize: true, 
       show: "clip", 
       hide: "clip", 
       height: 'auto', 
       width: 'auto', 
       autoOpen: false, 
       modal: true, 
       position: 'center', 
       draggable: false, 
       buttons: { 
       OK: function() { //ok 
        $(this).dialog("close"); 
       }, 
       Cancel: function() { //cancel 
        $(this).dialog("close"); 
       } 
      } 
       open: function (type, data) { 
        $(this).parent().appendTo("form"); 
       } 


      }); 
24

मिल कभी-कभी आप बटन गतिशील रूप से जोड़ने के लिए के बाद संवाद है चाहता हूँ सर्जन करना डी भी मेरी answer सवाल Add a button to a dialog box dynamically

var mydialog = ... result of jqueryui .dialog() 
var buttons = mydialog.dialog("option", "buttons"); // getter 
$.extend(buttons, { foo: function() { alert('foo'); } }); 
mydialog.dialog("option", "buttons", buttons); // setter 
+0

आप एक विशिष्ट आईडी के साथ एक बटन कैसे जोड़ देंगे? –

+0

आपको बटन पर एक आईडी क्यों चाहिए? – JJS

+0

या क्या आपका मतलब है कि किसी आईडी द्वारा पहचाना गया मौजूदा बटन जोड़ें? – JJS

10

में मिलते हैं आप एक संवाद है कि पहले से ही आप की तरह कुछ कर सकते हैं खोलने के लिए एक बटन को जोड़ना चाहते हैं:

var buttonSet = $('#dialog').parent().find('.ui-dialog-buttonset'); 
var newButton = $('<button>My New Button</button>'); 
newButton.button().click(function() { 
    alert('My new button clicked'); 
}); 
buttonSet.append(newButton); 
संबंधित मुद्दे